maven-remote-resources-plugin-1.6.0/ 0000775 0001750 0001750 00000000000 13365361414 017303 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/ 0000775 0001750 0001750 00000000000 13365361410 020066 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/ 0000775 0001750 0001750 00000000000 13365361410 021045 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/resources/ 0000775 0001750 0001750 00000000000 13365361410 023057 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/resources/SIMPLE.txt 0000664 0001750 0001750 00000001405 13365361410 024611 0 ustar mathieu mathieu Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Simple Text File
maven-remote-resources-plugin-1.6.0/src/test/resources/UTF-8.bin.vm 0000664 0001750 0001750 00000000016 13365361410 024772 0 ustar mathieu mathieu äöüÄÖÜß maven-remote-resources-plugin-1.6.0/src/test/resources/FILTER.txt.vm 0000664 0001750 0001750 00000001713 13365361410 025230 0 ustar mathieu mathieu ## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements. See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership. The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied. See the License for the
## specific language governing permissions and limitations
## under the License.
Some filtered text:
project.name: ${project.name}
projectTimespan: ${projectTimespan}
projects: ${projects}
projectsSortedByOrganization: ${projectsSortedByOrganization}
maven-remote-resources-plugin-1.6.0/src/test/resources/unit/ 0000775 0001750 0001750 00000000000 13365361410 024036 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/resources/unit/rrmojotest/ 0000775 0001750 0001750 00000000000 13365361410 026246 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/resources/unit/rrmojotest/process-plugin-config.xml 0000664 0001750 0001750 00000002144 13365361410 033206 0 ustar mathieu mathieu
remote-resources-plugin-testmaven-remote-resources-plugin${localRepository}UTF-8
maven-remote-resources-plugin-1.6.0/src/test/resources/unit/rrmojotest/bundle-plugin-config.xml 0000664 0001750 0001750 00000001777 13365361410 033014 0 ustar mathieu mathieu
remote-resources-plugin-testmaven-remote-resources-plugin
maven-remote-resources-plugin-1.6.0/src/test/resources/PROPERTIES.txt.vm 0000664 0001750 0001750 00000001541 13365361410 025736 0 ustar mathieu mathieu ## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements. See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership. The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied. See the License for the
## specific language governing permissions and limitations
## under the License.
Some filtered text:
${testingPropertyOne}
${testingPropertyTwo}
maven-remote-resources-plugin-1.6.0/src/test/resources/ISO-8859-1.bin.vm 0000664 0001750 0001750 00000000007 13365361410 025372 0 ustar mathieu mathieu äöüÄÖÜß maven-remote-resources-plugin-1.6.0/src/test/java/ 0000775 0001750 0001750 00000000000 13365361410 021766 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/java/org/ 0000775 0001750 0001750 00000000000 13365361410 022555 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/ 0000775 0001750 0001750 00000000000 13365361410 023776 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/ 0000775 0001750 0001750 00000000000 13365361410 025104 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/ 0000775 0001750 0001750 00000000000 13365361410 026402 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/ 0000775 0001750 0001750 00000000000 13365361410 030414 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/ 0000775 0001750 0001750 00000000000 13365361410 031707 5 ustar mathieu mathieu ././@LongLink 0000644 0000000 0000000 00000000170 00000000000 011601 L ustar root root maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/RemoteRes0000664 0001750 0001750 00000052726 13365361410 033553 0 ustar mathieu mathieu package org.apache.maven.plugin.resources.remote;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
import org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Properties;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
import org.codehaus.plexus.util.IOUtil;
/**
* RemoteResources plugin Test Case
*/
public class RemoteResourcesMojoTest
extends AbstractMojoTestCase
{
static final String DEFAULT_BUNDLE_POM_PATH = "target/test-classes/unit/rrmojotest/bundle-plugin-config.xml";
static final String DEFAULT_PROCESS_POM_PATH = "target/test-classes/unit/rrmojotest/process-plugin-config.xml";
public void setUp()
throws Exception
{
super.setUp();
}
public void tearDown()
throws Exception
{
}
/**
* check test environment
*
* @throws Exception if any exception occurs
*/
public void testTestEnvironment()
throws Exception
{
// Perform lookup on the Mojo to make sure everything is ok
lookupProcessMojo();
}
public void testNoBundles()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-nobundles" );
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithDefaultSettings( project );
setupDefaultProject( project );
mojo.execute();
}
public void testCreateBundle()
throws Exception
{
buildResourceBundle( "default-createbundle",
null,
new String[] { "SIMPLE.txt" },
null );
}
public void testSimpleBundles()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-simplebundles" );
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project ,
new String[] {
"test:test:1.0"
} );
setupDefaultProject( project );
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
String path = repo.pathOf( new DefaultArtifact( "test",
"test",
VersionRange.createFromVersion( "1.0" ),
null,
"jar",
"",
new DefaultArtifactHandler() ) );
File file = new File( repo.getBasedir() + "/" + path + ".jar" );
file.getParentFile().mkdirs();
buildResourceBundle( "default-simplebundles-create",
null,
new String[] { "SIMPLE.txt" },
file );
mojo.execute();
file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
file = new File( file, "SIMPLE.txt" );
assertTrue( file.exists() );
}
public void testSimpleBundlesWithType()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-simplebundles" );
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project ,
new String[] {
"test:test:1.0:war"
} );
setupDefaultProject( project );
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
String path = repo.pathOf( new DefaultArtifact( "test",
"test",
VersionRange.createFromVersion( "1.0" ),
null,
"war",
"",
new DefaultArtifactHandler() ) );
File file = new File( repo.getBasedir() + "/" + path + ".war" );
file.getParentFile().mkdirs();
buildResourceBundle( "default-simplebundles-create",
null,
new String[] { "SIMPLE.txt" },
file );
mojo.execute();
file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
file = new File( file, "SIMPLE.txt" );
assertTrue( file.exists() );
}
public void testSimpleBundlesWithClassifier()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-simplebundles" );
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project ,
new String[] {
"test:test:1.0:jar:test"
} );
setupDefaultProject( project );
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
String path = repo.pathOf( new DefaultArtifact( "test",
"test",
VersionRange.createFromVersion( "1.0" ),
null,
"jar",
"test",
new DefaultArtifactHandler() ) );
File file = new File( repo.getBasedir() + "/" + path + ".jar" );
file.getParentFile().mkdirs();
buildResourceBundle( "default-simplebundles-create",
null,
new String[] { "SIMPLE.txt" },
file );
mojo.execute();
file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
file = new File( file, "SIMPLE.txt" );
assertTrue( file.exists() );
}
public void testVelocityUTF8()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-utf8" );
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project ,
new String[] {
"test:test:1.2"
} );
setupDefaultProject( project );
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
String path = repo.pathOf( new DefaultArtifact( "test",
"test",
VersionRange.createFromVersion( "1.2" ),
null,
"jar",
"",
new DefaultArtifactHandler() ) );
File file = new File( repo.getBasedir() + "/" + path + ".jar" );
file.getParentFile().mkdirs();
buildResourceBundle( "default-utf8-create",
"UTF-8",
new String[] { "UTF-8.bin.vm" },
file );
mojo.execute();
file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
file = new File( file, "UTF-8.bin" );
assertTrue( file.exists() );
InputStream in = new FileInputStream( file );
byte[] data = IOUtil.toByteArray( in );
in.close();
byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes( "UTF-8" );
assertTrue( Arrays.equals( expected, data ) );
}
public void testVelocityISO88591()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-iso88591" );
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project ,
new String[] {
"test:test:1.3"
} );
setupDefaultProject( project );
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
String path = repo.pathOf( new DefaultArtifact( "test",
"test",
VersionRange.createFromVersion( "1.3" ),
null,
"jar",
"",
new DefaultArtifactHandler() ) );
File file = new File( repo.getBasedir() + "/" + path + ".jar" );
file.getParentFile().mkdirs();
buildResourceBundle( "default-iso88591-create",
"ISO-8859-1",
new String[] { "ISO-8859-1.bin.vm" },
file );
mojo.execute();
file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
file = new File( file, "ISO-8859-1.bin" );
assertTrue( file.exists() );
InputStream in = new FileInputStream( file );
byte[] data = IOUtil.toByteArray( in );
in.close();
byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes( "ISO-8859-1" );
assertTrue( Arrays.equals( expected, data ) );
}
public void testFilteredBundles()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-filterbundles" );
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings( project ,
new String[] {
"test:test:1.1"
} );
setupDefaultProject( project );
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
String path = repo.pathOf( new DefaultArtifact( "test",
"test",
VersionRange.createFromVersion( "1.1" ),
null,
"jar",
"",
new DefaultArtifactHandler() ) );
File file = new File( repo.getBasedir() + "/" + path + ".jar" );
file.getParentFile().mkdirs();
buildResourceBundle( "default-filterbundles-create",
null,
new String[] { "FILTER.txt.vm" },
file );
mojo.execute();
// executing a second time (example: forked lifecycle) should still work
mojo.execute();
file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
file = new File( file, "FILTER.txt" );
assertTrue( file.exists() );
String data = FileUtils.fileRead( file );
assertTrue( data.contains( "project.name: Test Project default-filterbundles" ) );
assertTrue( data.contains( "projectTimespan: 2007-" ) );
assertTrue( data.contains( "projects: [" ) );
assertTrue( data.contains( "projectsSortedByOrganization: {" ) );
}
public void testFilteredBundlesWithProjectProperties()
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( "default-filterbundles-two" );
final ProcessRemoteResourcesMojo mojo =
lookupProcessMojoWithSettings( project, new String[]{"test-filtered-bundles:test-filtered-bundles:2"} );
mojo.includeProjectProperties = true;
setupDefaultProject( project );
project.addProperty( "testingPropertyOne", "maven" );
project.addProperty( "testingPropertyTwo", "rules" );
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
String path = repo.pathOf( new DefaultArtifact( "test-filtered-bundles", "test-filtered-bundles",
VersionRange.createFromVersion( "2" ), null, "jar", "",
new DefaultArtifactHandler() ) );
File file = new File( repo.getBasedir() + "/" + path + ".jar" );
file.getParentFile().mkdirs();
buildResourceBundle( "default-filterbundles-two-create", null, new String[]{"PROPERTIES.txt.vm"}, file );
mojo.execute();
// executing a second time (example: forked lifecycle) should still work
mojo.execute();
file = (File) getVariableValueFromObject( mojo, "outputDirectory" );
file = new File( file, "PROPERTIES.txt" );
assertTrue( file.exists() );
String data = FileUtils.fileRead( file );
assertTrue(data.contains("maven"));
assertTrue(data.contains("rules"));
}
protected void buildResourceBundle( String id,
String sourceEncoding,
String resourceNames[],
File jarName )
throws Exception
{
final MavenProjectResourcesStub project = createTestProject( id );
final File resourceDir = new File( project.getBasedir() + "/src/main/resources" );
final BundleRemoteResourcesMojo mojo = lookupBundleMojoWithSettings( project , resourceDir, sourceEncoding );
setupDefaultProject( project );
for ( String resourceName2 : resourceNames )
{
File resource = new File( resourceDir, resourceName2 );
URL source = getClass().getResource( "/" + resourceName2 );
FileUtils.copyURLToFile(source, resource);
}
mojo.execute();
File xmlFile = new File( project.getBasedir() + "/target/classes/META-INF/maven/remote-resources.xml" );
assertTrue( xmlFile.exists() );
String data = FileUtils.fileRead( xmlFile );
for ( String resourceName1 : resourceNames )
{
assertTrue( data.contains( resourceName1 ) );
}
if ( null != jarName )
{
JarOutputStream jar = new JarOutputStream( new FileOutputStream( jarName ) );
jar.putNextEntry( new ZipEntry( "META-INF/maven/remote-resources.xml" ) );
jar.write( data.getBytes() );
jar.closeEntry();
for ( String resourceName : resourceNames )
{
File resource = new File( resourceDir, resourceName );
InputStream in = new FileInputStream( resource );
jar.putNextEntry( new ZipEntry( resourceName ) );
IOUtil.copy( in, jar );
jar.closeEntry();
in.close();
}
jar.close();
}
}
protected MavenProjectResourcesStub createTestProject( final String testName )
throws Exception
{
// this will automatically create the isolated
// test environment
return new MavenProjectResourcesStub( testName );
}
protected void setupDefaultProject( final MavenProjectResourcesStub project )
throws Exception
{
// put this on the root dir
project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
project.setInceptionYear( "2007" );
// start creating the environment
project.setupBuildEnvironment();
}
protected BundleRemoteResourcesMojo lookupBundleMojo()
throws Exception
{
File pomFile = new File( getBasedir(), DEFAULT_BUNDLE_POM_PATH );
BundleRemoteResourcesMojo mojo = (BundleRemoteResourcesMojo) lookupMojo( "bundle", pomFile );
assertNotNull( mojo );
return mojo;
}
protected BundleRemoteResourcesMojo lookupBundleMojoWithDefaultSettings( final MavenProject project )
throws Exception
{
File resourceDir = new File( project.getBasedir() + "/src/main/resources" );
return lookupBundleMojoWithSettings( project, resourceDir, null );
}
protected BundleRemoteResourcesMojo lookupBundleMojoWithSettings( final MavenProject project,
File resourceDir, String sourceEncoding )
throws Exception
{
final BundleRemoteResourcesMojo mojo = lookupBundleMojo();
setVariableValueToObject( mojo, "resourcesDirectory", resourceDir );
setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
setVariableValueToObject( mojo, "sourceEncoding", sourceEncoding );
return mojo;
}
protected ProcessRemoteResourcesMojo lookupProcessMojo()
throws Exception
{
File pomFile = new File( getBasedir(), DEFAULT_PROCESS_POM_PATH );
ProcessRemoteResourcesMojo mojo = (ProcessRemoteResourcesMojo) lookupMojo( "process", pomFile );
assertNotNull( mojo );
return mojo;
}
protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings( final MavenProject project,
String bundles[] )
throws Exception
{
return lookupProcessMojoWithSettings( project, new ArrayList( Arrays.asList( bundles ) ) );
}
protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings( final MavenProject project,
ArrayList bundles )
throws Exception
{
final ProcessRemoteResourcesMojo mojo = lookupProcessMojo();
MavenSession session = new MavenSession( getContainer(),
null, //Settings settings,
null, //ArtifactRepository localRepository,
null, //EventDispatcher eventDispatcher,
new ReactorManager( new ArrayList() ),
Arrays.asList( "install" ),
project.getBasedir().toString(),
new Properties(),
Calendar.getInstance().getTime() );
setVariableValueToObject( mojo, "project", project );
setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
setVariableValueToObject( mojo, "resourceBundles", bundles );
setVariableValueToObject( mojo, "mavenSession", session );
setVariableValueToObject( mojo, "remoteArtifactRepositories", project.getRemoteArtifactRepositories() );
setVariableValueToObject( mojo, "resources", project.getResources() );
return mojo;
}
protected ProcessRemoteResourcesMojo lookupProcessMojoWithDefaultSettings( final MavenProject project )
throws Exception
{
return lookupProcessMojoWithSettings( project, new ArrayList() );
}
}
maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/ 0000775 0001750 0001750 00000000000 13365361410 032664 5 ustar mathieu mathieu ././@LongLink 0000644 0000000 0000000 00000000173 00000000000 011604 L ustar root root maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBuildStub.java maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/Mave0000664 0001750 0001750 00000021235 13365361410 033502 0 ustar mathieu mathieu package org.apache.maven.plugin.resources.remote.stub;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.maven.model.Build;
import org.codehaus.plexus.util.FileUtils;
/**
* Stub
*/
public class MavenProjectBuildStub
extends MavenProjectBasicStub
{
public static final int RESOURCES_FILE = 1;
public static final int ROOT_FILE = 2;
public static final int OUTPUT_FILE = 3;
public static final int SOURCE_FILE = 4;
protected Build build;
protected String srcDirectory;
protected String targetDirectory;
protected String buildDirectory;
protected String outputDirectory;
protected String testOutputDirectory;
protected String resourcesDirectory;
protected String testResourcesDirectory;
protected String targetResourceDirectory;
protected String targetTestResourcesDirectory;
protected ArrayList targetClassesList;
protected ArrayList sourceFileList;
protected ArrayList resourcesFileList;
protected ArrayList rootFileList;
protected ArrayList directoryList;
protected HashMap dataMap;
public MavenProjectBuildStub( String key )
throws Exception
{
super( key );
build = new Build();
resourcesFileList = new ArrayList();
sourceFileList = new ArrayList();
rootFileList = new ArrayList();
directoryList = new ArrayList();
targetClassesList = new ArrayList();
dataMap = new HashMap();
setupBuild();
}
public void addDirectory( String name )
{
if ( isValidPath( name ) )
{
directoryList.add( name );
}
}
public void setOutputDirectory( String dir )
{
outputDirectory = buildDirectory + "/" + dir;
build.setOutputDirectory( outputDirectory );
}
public void addFile( String name, int type )
{
if ( isValidPath( name ) )
{
List list = getList( type );
list.add( name );
}
}
public void addFile( String name, String data, int type )
{
File fileName = new File( name );
addFile( name, type );
dataMap.put( fileName.getName(), data );
}
public String getOutputDirectory()
{
return outputDirectory;
}
public String getTestOutputDirectory()
{
return testOutputDirectory;
}
public String getResourcesDirectory()
{
return resourcesDirectory;
}
public String getTestResourcesDirectory()
{
return testResourcesDirectory;
}
public Build getBuild()
{
return build;
}
/**
* returns true if the path is relative
* and false if absolute
* also returns false if it is relative to
* the parent
*
* @param path
* @return
*/
private boolean isValidPath( String path )
{
boolean bRetVal = true;
if ( path.startsWith( "c:" ) || path.startsWith( ".." ) || path.startsWith( "/" ) || path.startsWith( "\\" ) )
{
bRetVal = false;
}
return bRetVal;
}
private void setupBuild()
{
// check getBasedir method for the exact path
// we need to recreate the dir structure in
// an isolated environment
srcDirectory = testRootDir + "/src";
buildDirectory = testRootDir + "/target";
outputDirectory = buildDirectory + "/classes";
testOutputDirectory = buildDirectory + "/test-classes";
resourcesDirectory = srcDirectory + "/main/resources/";
testResourcesDirectory = srcDirectory + "/test/resources/";
build.setDirectory( buildDirectory );
build.setOutputDirectory( outputDirectory );
build.setTestOutputDirectory( testOutputDirectory );
}
public void setupBuildEnvironment()
throws Exception
{
// populate dummy resources and dummy test resources
// setup src dir
if ( !FileUtils.fileExists( resourcesDirectory ) )
{
FileUtils.mkdir( resourcesDirectory );
}
if ( !FileUtils.fileExists( testResourcesDirectory ) )
{
FileUtils.mkdir( testResourcesDirectory );
}
createDirectories( resourcesDirectory, testResourcesDirectory );
createFiles( resourcesDirectory, testResourcesDirectory );
setupRootFiles();
// setup target dir
if ( !FileUtils.fileExists( outputDirectory ) )
{
FileUtils.mkdir( outputDirectory );
}
if ( !FileUtils.fileExists( testOutputDirectory ) )
{
FileUtils.mkdir( testOutputDirectory );
}
setupTargetFiles();
}
private void createDirectories( String parent, String testparent )
{
File currentDirectory;
for ( String aDirectoryList : directoryList )
{
currentDirectory = new File( parent, "/" + aDirectoryList );
if ( !currentDirectory.exists() )
{
currentDirectory.mkdirs();
}
// duplicate dir structure in test resources
currentDirectory = new File( testparent, "/" + aDirectoryList );
if ( !currentDirectory.exists() )
{
currentDirectory.mkdirs();
}
}
}
private List getList( int type )
{
ArrayList retVal = null;
switch ( type )
{
case SOURCE_FILE :
retVal = sourceFileList;
break;
case OUTPUT_FILE :
retVal = targetClassesList;
break;
case RESOURCES_FILE :
retVal = resourcesFileList;
break;
case ROOT_FILE :
retVal = rootFileList;
break;
}
return retVal;
}
private void createFiles( String parent, int type )
{
File currentFile;
List list = getList( type );
// guard
if ( list == null )
{
return;
}
for ( String aList : list )
{
currentFile = new File( parent, aList );
// create the necessary parent directories
// before we create the files
if ( !currentFile.getParentFile().exists() )
{
currentFile.getParentFile().mkdirs();
}
if ( !currentFile.exists() )
{
try
{
currentFile.createNewFile();
populateFile( currentFile, RESOURCES_FILE );
}
catch ( IOException io )
{
// TODO: handle exception
}
}
}
}
private void setupRootFiles()
{
createFiles( testRootDir, ROOT_FILE );
}
private void setupTargetFiles()
{
createFiles( getOutputDirectory(), OUTPUT_FILE );
}
private void createFiles( String parent, String testparent )
{
createFiles( parent, RESOURCES_FILE );
createFiles( testparent, RESOURCES_FILE );
}
private void populateFile( File file, int type )
{
FileOutputStream outputStream;
String data = dataMap.get( file.getName() );
if ( ( data != null ) && file.exists() )
{
try
{
outputStream = new FileOutputStream( file );
outputStream.write( data.getBytes() );
outputStream.flush();
outputStream.close();
}
catch ( IOException ex )
{
// TODO: handle exception here
}
}
}
}
././@LongLink 0000644 0000000 0000000 00000000157 00000000000 011606 L ustar root root maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/ModelStub.java maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/Mode0000664 0001750 0001750 00000003332 13365361410 033474 0 ustar mathieu mathieu package org.apache.maven.plugin.resources.remote.stub;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.util.Properties;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
/**
* Stub
*/
public class ModelStub
extends Model
{
private static final long serialVersionUID = 1L;
public ModelStub()
{
}
public String getVersion()
{
return "0.0-TEST";
}
public String getModelVersion()
{
return "0.0-TEST";
}
public String getName()
{
return "Test Model";
}
public String getGroupId()
{
return "org.apache.maven.test";
}
public String getPackaging()
{
return "jar";
}
public Parent getParent()
{
//return new Parent();
return null;
}
public String getArtifactId()
{
return "maven-test-plugin";
}
public Properties getProperties()
{
return new Properties();
}
}
././@LongLink 0000644 0000000 0000000 00000000177 00000000000 011610 L ustar root root maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectResourcesStub.java maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/Mave0000664 0001750 0001750 00000006154 13365361410 033505 0 ustar mathieu mathieu package org.apache.maven.plugin.resources.remote.stub;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.model.Resource;
/**
* Stub
*/
public class MavenProjectResourcesStub
extends MavenProjectBuildStub
{
public MavenProjectResourcesStub( String id )
throws Exception
{
super( id );
setupResources();
setupTestResources();
}
public void addInclude( String pattern )
{
build.getResources().get( 0 ).addInclude(pattern);
}
public void addExclude( String pattern )
{
build.getResources().get( 0 ).addExclude(pattern);
}
public void addTestInclude( String pattern )
{
build.getTestResources().get( 0 ).addInclude(pattern);
}
public void addTestExclude( String pattern )
{
build.getTestResources().get( 0 ).addExclude(pattern);
}
public void setTargetPath( String path )
{
build.getResources().get( 0 ).setTargetPath(path);
}
public void setTestTargetPath( String path )
{
build.getTestResources().get( 0 ).setTargetPath(path);
}
public void setDirectory( String dir )
{
build.getResources().get( 0 ).setDirectory(dir);
}
public void setTestDirectory( String dir )
{
build.getTestResources().get( 0 ).setDirectory(dir);
}
public void setResourceFiltering( int nIndex, boolean filter )
{
if ( build.getResources().size() > nIndex )
{
build.getResources().get( nIndex ).setFiltering(filter);
}
}
private void setupResources()
{
Resource resource = new Resource();
// see MavenProjectBasicStub for details
// of getBasedir
// setup default resources
resource.setDirectory( getBasedir().getPath() + "/src/main/resources" );
resource.setFiltering( false );
resource.setTargetPath( null );
build.addResource( resource );
}
private void setupTestResources()
{
Resource resource = new Resource();
// see MavenProjectBasicStub for details
// of getBasedir
// setup default test resources
resource.setDirectory( getBasedir().getPath() + "/src/test/resources" );
resource.setFiltering( false );
resource.setTargetPath( null );
build.addTestResource( resource );
}
}
././@LongLink 0000644 0000000 0000000 00000000162 00000000000 011602 L ustar root root maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/ArtifactStub.java maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/Arti0000664 0001750 0001750 00000014523 13365361410 033513 0 ustar mathieu mathieu package org.apache.maven.plugin.resources.remote.stub;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
/**
* Stub
*/
public class ArtifactStub
implements Artifact
{
boolean hasClassifier;
boolean resolved;
boolean optional;
boolean release;
ArtifactHandler artifactHandler;
File file;
String baseVersion;
String type;
String classifier;
String identifier;
String dependencyConflictId;
String downloadUrl;
String selectedVersion;
String artifactId;
String groupId;
String resolvedVersion;
String scope;
String version;
VersionRange versionRange;
public ArtifactStub()
{
type = "testtype";
scope = "testscope";
classifier = "testclassifier";
artifactHandler = new DefaultArtifactHandler();
}
public void populate( MavenProjectBasicStub project )
{
groupId = project.getGroupId();
artifactId = project.getArtifactId();
version = project.getVersion();
versionRange = VersionRange.createFromVersion( version );
}
public boolean hasClassifier()
{
return true;
}
public String getBaseVersion()
{
return "Test Version";
}
public void setBaseVersion( String version )
{
baseVersion = version;
}
public void setFile( File _file )
{
file = _file;
}
public File getFile()
{
return new File( "testfile" );
}
public String getGroupId()
{
return groupId;
}
public String getArtifactId()
{
return artifactId;
}
public String getVersion()
{
return version;
}
public void setVersion( String _version )
{
version = _version;
}
public String getScope()
{
return scope;
}
public String getType()
{
return type;
}
public String getClassifier()
{
return classifier;
}
public String getId()
{
return identifier;
}
public String getDependencyConflictId()
{
return dependencyConflictId;
}
public void addMetadata( ArtifactMetadata metadata )
{
}
public Collection getMetadataList()
{
return new LinkedList();
}
public void setRepository( ArtifactRepository remoteRepository )
{
}
public ArtifactRepository getRepository()
{
return null;
}
public void updateVersion( String version, ArtifactRepository localRepository )
{
}
public String getDownloadUrl()
{
return downloadUrl;
}
public void setDownloadUrl( String _downloadUrl )
{
downloadUrl = _downloadUrl;
}
public ArtifactFilter getDependencyFilter()
{
return null;
}
public void setDependencyFilter( ArtifactFilter artifactFilter )
{
}
public ArtifactHandler getArtifactHandler()
{
return artifactHandler;
}
public List getDependencyTrail()
{
return new LinkedList();
}
public void setDependencyTrail(List dependencyTrail)
{
}
public void setScope( String _scope )
{
scope = _scope;
}
public VersionRange getVersionRange()
{
return versionRange;
}
public void setVersionRange( VersionRange newRange )
{
}
public void selectVersion( String version )
{
selectedVersion = version;
}
public void setGroupId( String _groupId )
{
groupId = _groupId;
}
public void setArtifactId( String _artifactId )
{
artifactId = _artifactId;
}
public boolean isSnapshot()
{
return true;
}
public void setResolved( boolean _resolved )
{
resolved = _resolved;
}
public boolean isResolved()
{
return true;
}
public void setResolvedVersion( String version )
{
resolvedVersion = version;
}
public void setArtifactHandler( ArtifactHandler handler )
{
}
public boolean isRelease()
{
return true;
}
public void setRelease( boolean _release )
{
release = _release;
}
public List getAvailableVersions()
{
return new LinkedList();
}
public void setAvailableVersions(List versions)
{
}
public boolean isOptional()
{
return true;
}
public void setOptional( boolean _optional )
{
optional = _optional;
}
public ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException
{
return null;
}
public boolean isSelectedVersionKnown()
throws OverConstrainedVersionException
{
return true;
}
public int compareTo(Artifact o) {
return 0;
}
public ArtifactMetadata getMetadata(Class> metadataClass) {
return null;
}
}
././@LongLink 0000644 0000000 0000000 00000000173 00000000000 011604 L ustar root root maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/MavenProjectBasicStub.java maven-remote-resources-plugin-1.6.0/src/test/java/org/apache/maven/plugin/resources/remote/stub/Mave0000664 0001750 0001750 00000010356 13365361410 033504 0 ustar mathieu mathieu package org.apache.maven.plugin.resources.remote.stub;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Properties;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
/**
* Stub
*/
public class MavenProjectBasicStub
extends MavenProject
{
protected String identifier;
protected String testRootDir;
protected Properties properties;
protected String description;
protected ModelStub modelStub;
protected File file;
protected ArtifactStub artifact;
public MavenProjectBasicStub( String id )
throws Exception
{
// most values are hardcoded to have a controlled environment
super( new ModelStub() );
modelStub = (ModelStub) getModel();
properties = new Properties();
artifact = new ArtifactStub();
identifier = id;
// set isolated root directory
testRootDir = PlexusTestCase.getBasedir() + "/target/test-classes/unit/test-dir/" + identifier;
if ( !FileUtils.fileExists( testRootDir ) )
{
FileUtils.mkdir( testRootDir );
}
artifact.populate( this );
// this is ugly but needed to ensure that the copy constructor
// works correctly
initializeParentFields();
}
public String getName()
{
return "Test Project " + identifier;
}
public void setDescription( String desc )
{
description = desc;
}
public String getDescription()
{
if ( description == null )
{
return "this is a test project";
}
else
{
return description;
}
}
public File getBasedir()
{
// create an isolated environment
// see setupTestEnvironment for details
return new File( testRootDir );
}
public Artifact getArtifact()
{
return artifact;
}
public String getGroupId()
{
return "org.apache.maven.plugin.test";
}
public String getArtifactId()
{
return "maven-resource-plugin-test#" + identifier;
}
public String getPackaging()
{
return "ejb";
}
public String getVersion()
{
return identifier;
}
public void addProperty( String key, String value )
{
properties.put( key, value );
}
public Properties getProperties()
{
return properties;
}
// to prevent the MavenProject copy constructor from blowing up
private void initializeParentFields()
{
// the pom should be located in the isolated dummy root
super.setFile( new File( getBasedir(), "pom.xml" ) );
super.setDependencyArtifacts( new HashSet
[if-any logo]
[end]
The currently selected mirror is
[preferred].
If you encounter a problem with this mirror,
please select another mirror.
If all mirrors are failing, there are
backup
mirrors
(at the end of the mirrors list) that should be available.
Older non-recommended releases can be found on our archive site.
maven-remote-resources-plugin-1.6.0/src/site/fml/ 0000775 0001750 0001750 00000000000 13365361410 021610 5 ustar mathieu mathieu maven-remote-resources-plugin-1.6.0/src/site/fml/faq.fml 0000664 0001750 0001750 00000007400 13365361410 023060 0 ustar mathieu mathieu
Why do I need to use this plugin?
This plugin greatly reduces the pain associated with consistent packaging concerns across
a large set of projects, or an entire organization. Any project can specify the use of a
remote resource bundle and have the resources incorporated into their packaging. This means
that you can create standard settings in a parent POM somewhere in the project hierarchy and
have all projects use packaged common resources in a standard way like licenses, other legal
notices and disclaimers, or anything else that may be common.
The generated files have a lot of missing information. Looking at the POMs from
the dependencies, the information isn't there either. What can I do?
There are two solutions:
File bugs with the projects that produced those artifacts to get them to fix them. Also,
file bugs with the
Maven Evangelism
project to have the Maven people enhance the metadata in the repository.
Use a supplemental data file. You can create a file that contains the missing metadata.
For example:
com.sun.xml.bindjaxb-implSun JAXB Reference Implementation RuntimeSun Microsystemshttp://www.sun.com/COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0http://www.sun.com/cddl/cddl.html
]]>
That location of that file can then be configured with the
supplementalModels configuration element for the process goal. The
supplemental information is merged with the information provided from the repository.