Author: jvanzyl
Date: Sat Jan 13 19:36:16 2007
New Revision: 496027
URL: http://svn.apache.org/viewvc?view=rev&rev=496027
Log:
o little refactoring and did MSOURCES-11 and MSOURCES-6 but I need to add a
test for that yet.
Added:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
- copied, changed from r495459,
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractJarSourceMojo.java
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java
- copied, changed from r495459,
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java
- copied, changed from r495459,
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarTestSourceMojo.java
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceJarMojoTest.java
- copied, changed from r495459,
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/TestSourceJarMojoTest.java
- copied, changed from r495459,
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java
Removed:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractJarSourceMojo.java
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarTestSourceMojo.java
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java
Modified:
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/custom-configuration/custom-configuration-config.xml
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/default-configuration/default-configuration-config.xml
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/invalid-packaging/invalid-packaging-config.xml
Copied:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
(from r495459,
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractJarSourceMojo.java)
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java?view=diff&rev=496027&p1=maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractJarSourceMojo.java&r1=495459&p2=maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractJarSourceMojo.java
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
Sat Jan 13 19:36:16 2007
@@ -31,10 +31,11 @@
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-public abstract class AbstractJarSourceMojo
+public abstract class AbstractSourceJarMojo
extends AbstractMojo
{
private static final String[] DEFAULT_INCLUDES = new String[]{"**/*",};
@@ -94,113 +95,145 @@
*/
protected String finalName;
- /** @see org.apache.maven.plugin.AbstractMojo#execute() */
- public abstract void execute()
- throws MojoExecutionException;
+ //MAPI: how to programatically tell maven we will do aggregation, so that
I don't have to create a separate mojo.
+ // we just want to do the right thing 99% of the time. Would be know
by running with other goals what to do.
+ // sources/javadoc: what are the cases
+ //
+ //MAPI: how to make this backward compatible
- public MavenProject getProject()
- {
- return project;
- }
+ /** @parameter expression="${aggregate}" default-value="true" */
+ protected boolean aggregate;
- public void setProject( MavenProject project )
- {
- this.project = project;
- }
+ /** @parameter expression="${reactorProjects}" */
+ protected List reactorProjects;
- public String getPackaging()
- {
- return packaging;
- }
+ protected abstract String getClassifier();
- public void setPackaging( String packaging )
- {
- this.packaging = packaging;
- }
+ protected abstract List getSources( MavenProject project );
+
+ protected abstract List getResources( MavenProject project );
- public MavenProject getExecutedProject()
+ /** @see org.apache.maven.plugin.AbstractMojo#execute() */
+ public void execute()
+ throws MojoExecutionException
{
- return executedProject;
+ // This is working around a problem with the test harness where the
reactorProjects is always null.
+
+ if ( reactorProjects != null )
+ {
+ packageSources( reactorProjects );
+ }
+ else
+ {
+ packageSources( Arrays.asList( new Object[]{project} ) );
+ }
}
- public void setExecutedProject( MavenProject executedProject )
+ protected void packageSources( List projects )
+ throws MojoExecutionException
{
- this.executedProject = executedProject;
+ if ( "pom".equals( packaging ) && !aggregate )
+ {
+ getLog().info( "NOT adding sources to attached artifacts for packaging: \'"
+ packaging + "\'." );
+ }
+ else
+ {
+ if ( project.getArtifact().getClassifier() != null )
+ {
+ getLog().warn(
+ "NOT adding sources to artifacts with classifier as Maven only
supports one classifier " +
+ "per artifact. Current artifact [" +
project.getArtifact().getId() + "] has a [" +
+ project.getArtifact().getClassifier() + "]
classifier." );
+ }
+ else
+ {
+ Archiver archiver = createArchiver();
+
+ for ( Iterator i = projects.iterator(); i.hasNext(); )
+ {
+ MavenProject p = (MavenProject) i.next();
+
+ archiveProjectContent( p, archiver );
+ }
+
+ File outputFile = new File( outputDirectory, finalName + "-" +
getClassifier() + ".jar" );
+
+ try
+ {
+ archiver.setDestFile( outputFile );
+
+ archiver.createArchive();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error creating source
archive: " + e.getMessage(), e );
+ }
+ catch ( ArchiverException e )
+ {
+ throw new MojoExecutionException( "Error creating source
archive: " + e.getMessage(), e );
+ }
+
+ if ( attach )
+ {
+ projectHelper.attachArtifact( project, "java-source",
getClassifier(), outputFile );
+ }
+ }
+ }
}
- /**
- * Add the compile source directories and resource directories that will
be included in the jar file
- *
- * @param compileSourceRoots
- * @param resources
- * @param sourceDirectories
- * @return an array of File objects that contains the directories that
will be included in the jar file
- */
- protected File[] addDirectories( List compileSourceRoots,
- List resources,
- File[] sourceDirectories )
+ protected void archiveProjectContent( MavenProject project,
+ Archiver archiver )
+ throws MojoExecutionException
{
- int count = 0;
- for ( Iterator i = compileSourceRoots.iterator(); i.hasNext(); )
+ for ( Iterator i = getSources( project ).iterator(); i.hasNext(); )
{
- sourceDirectories[count] = new File( (String) i.next() );
- count++;
+ String s = (String) i.next();
+
+ File sourceDirectory = new File( s );
+
+ if ( sourceDirectory.exists() )
+ {
+ addDirectory( archiver, sourceDirectory, DEFAULT_INCLUDES,
FileUtils.getDefaultExcludes() );
+ }
}
- for ( Iterator i = resources.iterator(); i.hasNext(); )
+ for ( Iterator i = getResources( project ).iterator(); i.hasNext(); )
{
Resource resource = (Resource) i.next();
- sourceDirectories[count] = new File( resource.getDirectory() );
- count++;
- }
- return sourceDirectories;
- }
+ File sourceDirectory = new File( resource.getDirectory() );
- /**
- * Get the test sources that will be included in the test sources jar file
- *
- * @return an array of File objects that contains the test source
directories
- */
- protected File[] getTestSources()
- {
- List testCompileSourceRoots =
executedProject.getTestCompileSourceRoots();
- List testResources = executedProject.getTestResources();
+ if ( sourceDirectory.exists() )
+ {
+ List resourceIncludes = resource.getIncludes();
- File[] testSourceDirectories = new File[testCompileSourceRoots.size() + testResources.size()];
- testSourceDirectories = addDirectories( testCompileSourceRoots,
testResources, testSourceDirectories );
+ String includes[];
- return testSourceDirectories;
- }
+ if ( resourceIncludes == null || resourceIncludes.size() == 0 )
+ {
+ includes = DEFAULT_INCLUDES;
+ }
+ else
+ {
+ includes = (String[]) resourceIncludes.toArray( new
String[resourceIncludes.size()] );
+ }
- /**
- * Get the main sources that will be included in the jar file
- *
- * @return an array of File objects that contains the source directories
- */
- protected File[] getDefaultSources()
- {
- List compileSourceRoots = executedProject.getCompileSourceRoots();
- List resources = executedProject.getResources();
+ List resourceExcludes = resource.getExcludes();
- File[] sourceDirectories = new File[compileSourceRoots.size() + resources.size()];
- sourceDirectories = addDirectories( compileSourceRoots, resources,
sourceDirectories );
+ String[] excludes;
- return sourceDirectories;
- }
+ if ( resourceIncludes == null || resourceIncludes.size() == 0 )
+ {
+ excludes = FileUtils.getDefaultExcludes();
+ }
+ else
+ {
+ excludes = (String[]) resourceExcludes.toArray( new
String[resourceExcludes.size()] );
+ }
- /**
- * Create jar file that contains the specified source directories
- *
- * @param outputFile the file name of the jar
- * @param sourceDirectories the source directories that will be included
in the jar file
- */
- protected void createJar( File outputFile,
- File[] sourceDirectories,
- Archiver archiver )
- throws IOException, ArchiverException
- {
- makeSourceBundle( outputFile, sourceDirectories, archiver );
+ addDirectory( archiver, sourceDirectory, includes, excludes );
+ }
+ }
}
/**
@@ -212,49 +245,10 @@
protected void attachArtifact( File outputFile,
String classifier )
{
- if ( !attach )
- {
- getLog().info( "NOT adding java-sources to attached artifacts
list." );
- }
- else
- {
- // TODO: these introduced dependencies on the project are going to
become problematic - can we export it
- // through metadata instead?
- projectHelper.attachArtifact( project, "java-source", classifier,
outputFile );
- }
- }
-
- /**
- * Method to create an archive of the specified files
- *
- * @param outputFile the destination file of the generated archive
- * @param sourceDirectories the directory where the files to be archived
are located
- * @param archiver the archiver object that will create the
archive
- * @throws ArchiverException
- * @throws IOException
- */
- protected void makeSourceBundle( File outputFile,
- File[] sourceDirectories,
- Archiver archiver )
- throws ArchiverException, IOException
- {
- String[] includes = DEFAULT_INCLUDES;
-
- for ( int i = 0; i < sourceDirectories.length; i++ )
- {
- if ( sourceDirectories[i].exists() )
- {
- archiver.addDirectory( sourceDirectories[i], includes,
FileUtils.getDefaultExcludes() );
- }
- }
-
- archiver.setDestFile( outputFile );
-
- archiver.createArchive();
}
protected Archiver createArchiver()
- throws ArchiverException
+ throws MojoExecutionException
{
Archiver archiver = new JarArchiver();
@@ -268,13 +262,27 @@
if ( r.getDirectory().endsWith( "maven-shared-archive-resources" ) )
{
- archiver.addDirectory( new File( r.getDirectory() ) );
+ addDirectory( archiver, new File( r.getDirectory() ), new
String[]{}, new String[]{} );
}
}
-
- //archiver.setDotFileDirectory( new File(
project.getBuild().getDirectory() ) );
}
return archiver;
+ }
+
+ protected void addDirectory( Archiver archiver,
+ File sourceDirectory,
+ String[] includes,
+ String[] excludes )
+ throws MojoExecutionException
+ {
+ try
+ {
+ archiver.addDirectory( sourceDirectory, includes, excludes );
+ }
+ catch ( ArchiverException e )
+ {
+ throw new MojoExecutionException( "Error adding directory to source
archive.", e );
+ }
}
}
Added:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java?view=auto&rev=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java
(added)
+++
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java
Sat Jan 13 19:36:16 2007
@@ -0,0 +1,12 @@
+package org.apache.maven.plugin.source;
+
+/**
+ * @goal aggregate
+ * @phase package
+ * @aggregator
+ * @execute phase="generate-sources"
+ */
+public class AggregatorSourceJarMojo
+ extends SourceJarMojo
+{
+}
Copied:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java
(from r495459,
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java)
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java?view=diff&rev=496027&p1=maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java&r1=495459&p2=maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java
Sat Jan 13 19:36:16 2007
@@ -1,85 +1,55 @@
-package org.apache.maven.plugin.source;
-
-/*
- * 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.plugin.MojoExecutionException;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.jar.JarArchiver;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * This plugin bundles all the sources into a jar archive.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a>
- * @version $Id: AbstractJarSourceMojo.java 389062 2006-03-27 08:19:25Z
aramirez $
- * @goal jar
- * @phase package
- * @execute phase="generate-sources"
- */
-public class JarDefaultSourceMojo
- extends AbstractJarSourceMojo
-{
- /**
- * @see org.apache.maven.plugin.AbstractMojo#execute()
- */
- public void execute()
- throws MojoExecutionException
- {
- if ( "pom".equals( packaging ) )
- {
- getLog().info( "NOT adding sources to attached artifacts for packaging: \'"
+ packaging + "\'." );
- }
- else
- {
- // Do not attach source JAR for artifacts with classifier. This is
because Maven2 only supports a single
- // classifier per artifact. This is a limitation. See
http://jira.codehaus.org/browse/MSOURCES-10.
- if ( getProject().getArtifact().getClassifier() != null )
- {
- getLog().warn( "NOT adding sources to artifacts with classifier as
Maven only supports one classifier "
- + "per artifact. Current artifact [" +
getProject().getArtifact().getId() + "] has a ["
- + getProject().getArtifact().getClassifier() + "]
classifier.");
- }
- else
- {
- File outputFile = new File( outputDirectory, finalName +
"-sources.jar" );
-
- File[] sourceDirectories = getDefaultSources();
-
- try
- {
- createJar( outputFile, sourceDirectories, createArchiver()
);
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error creating source
archive: " + e.getMessage(), e );
- }
- catch ( ArchiverException e )
- {
- throw new MojoExecutionException( "Error creating source
archive: " + e.getMessage(), e );
- }
-
- attachArtifact( outputFile, "sources" );
- }
- }
- }
-
-}
+package org.apache.maven.plugin.source;
+
+/*
+ * 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.project.MavenProject;
+import org.apache.maven.model.Resource;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * This plugin bundles all the sources into a jar archive.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a>
+ * @version $Id: AbstractSourceJarMojo.java 389062 2006-03-27 08:19:25Z
aramirez $
+ * @goal jar
+ * @phase package
+ * @execute phase="generate-sources"
+ */
+public class SourceJarMojo
+ extends AbstractSourceJarMojo
+{
+ protected List getSources( MavenProject project )
+ {
+ return project.getCompileSourceRoots();
+ }
+
+ protected List getResources( MavenProject project )
+ {
+ return project.getResources();
+ }
+
+ protected String getClassifier()
+ {
+ return "sources";
+ }
+}
Copied:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java
(from r495459,
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarTestSourceMojo.java)
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java?view=diff&rev=496027&p1=maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarTestSourceMojo.java&r1=495459&p2=maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarTestSourceMojo.java
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java
Sat Jan 13 19:36:16 2007
@@ -1,71 +1,53 @@
-package org.apache.maven.plugin.source;
-
-/*
- * 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.plugin.MojoExecutionException;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.jar.JarArchiver;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * This plugin bundles all the test sources into a jar archive.
- *
- * @goal test-jar
- * @phase package
- * @execute phase="generate-sources"
- */
-public class JarTestSourceMojo
- extends AbstractJarSourceMojo
-{
- /**
- * @see org.apache.maven.plugin.AbstractMojo#execute()
- */
- public void execute()
- throws MojoExecutionException
- {
- if ( "pom".equals( packaging ) )
- {
- getLog().info( "NOT adding test sources to attached artifacts for packaging:
\'" + packaging + "\'." );
- }
- else
- {
- File outputFile = new File( outputDirectory, finalName +
"-test-sources.jar" );
- File[] testSourceDirectories = getTestSources();
-
- try
- {
- createJar( outputFile, testSourceDirectories, createArchiver()
);
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error creating source archive:
" + e.getMessage(), e );
- }
- catch ( ArchiverException e )
- {
- throw new MojoExecutionException( "Error creating source archive:
" + e.getMessage(), e );
- }
-
- attachArtifact( outputFile, "test-sources" );
- }
- }
-
-}
+package org.apache.maven.plugin.source;
+
+/*
+ * 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.project.MavenProject;
+import org.apache.maven.model.Resource;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * This plugin bundles all the test sources into a jar archive.
+ *
+ * @goal test-jar
+ * @phase package
+ * @execute phase="generate-sources"
+ */
+public class TestSourceJarMojo
+ extends AbstractSourceJarMojo
+{
+ protected List getSources( MavenProject project )
+ {
+ return project.getTestCompileSourceRoots();
+ }
+
+ protected List getResources( MavenProject project )
+ {
+ return project.getTestResources();
+ }
+
+ protected String getClassifier()
+ {
+ return "test-sources";
+ }
+}
Copied:
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceJarMojoTest.java
(from r495459,
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java)
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceJarMojoTest.java?view=diff&rev=496027&p1=maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java&r1=495459&p2=maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceJarMojoTest.java&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarDefaultSourceMojoTest.java
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceJarMojoTest.java
Sat Jan 13 19:36:16 2007
@@ -30,10 +30,9 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Maria Odea Ching</a>
*/
-public class JarDefaultSourceMojoTest
+public class SourceJarMojoTest
extends AbstractMojoTestCase
{
-
protected void setUp()
throws Exception
{
@@ -50,17 +49,21 @@
try
{
- JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo(
"jar", testPom );
+ SourceJarMojo mojo = (SourceJarMojo) lookupMojo( "jar", testPom );
+
mojo.execute();
}
catch ( Exception e )
{
+ fail( "Cannot execute mojo!" );
+
e.printStackTrace();
}
//check if the jar file exists
File sourceJar =
new File( getBasedir(),
"target/test/unit/default-configuration/target/default-configuration-sources.jar"
);
+
assertTrue( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
ZipFile jar = new ZipFile( sourceJar );
@@ -100,7 +103,8 @@
try
{
- JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo(
"jar", testPom );
+ SourceJarMojo mojo = (SourceJarMojo) lookupMojo( "jar", testPom );
+
mojo.execute();
}
catch ( Exception e )
@@ -111,6 +115,7 @@
//check if the jar file exists
File sourceJar =
new File( getBasedir(),
"target/test/unit/custom-configuration/target/custom-configuration-sources.jar"
);
+
assertTrue( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
//verify the contents of the jar file
@@ -150,7 +155,7 @@
try
{
- JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo(
"jar", testPom );
+ SourceJarMojo mojo = (SourceJarMojo) lookupMojo( "jar", testPom );
mojo.execute();
}
catch ( Exception e )
@@ -172,11 +177,13 @@
try
{
- JarDefaultSourceMojo mojo = (JarDefaultSourceMojo) lookupMojo(
"jar", testPom );
+ SourceJarMojo mojo = (SourceJarMojo) lookupMojo( "jar", testPom );
+
mojo.execute();
- assertNotNull( mojo.getPackaging() );
- assertNotNull( mojo.getProject() );
- assertNotNull( mojo.getExecutedProject() );
+
+ //assertNotNull( mojo.getPackaging() );
+ //assertNotNull( mojo.getProject() );
+ //assertNotNull( mojo.getExecutedProject() );
}
catch ( Exception e )
{
Copied:
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/TestSourceJarMojoTest.java
(from r495459,
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java)
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/TestSourceJarMojoTest.java?view=diff&rev=496027&p1=maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java&r1=495459&p2=maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/TestSourceJarMojoTest.java&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/JarTestSourceMojoTest.java
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/TestSourceJarMojoTest.java
Sat Jan 13 19:36:16 2007
@@ -30,7 +30,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Maria Odea Ching</a>
*/
-public class JarTestSourceMojoTest
+public class TestSourceJarMojoTest
extends AbstractMojoTestCase
{
@@ -51,17 +51,20 @@
try
{
- JarTestSourceMojo mojo = (JarTestSourceMojo) lookupMojo(
"test-jar", testPom );
+ TestSourceJarMojo mojo = (TestSourceJarMojo) lookupMojo(
"test-jar", testPom );
mojo.execute();
}
catch ( Exception e )
{
+ fail( "Cannot execute mojo." );
+
e.printStackTrace();
}
//check if the jar file exists
File sourceJar = new File( getBasedir(),
"target/test/unit/default-configuration/target/default-configuration-test-sources.jar"
);
+
assertTrue( FileUtils.fileExists( sourceJar.getAbsolutePath() ) );
ZipFile jar = new ZipFile( sourceJar );
@@ -99,7 +102,7 @@
try
{
- JarTestSourceMojo mojo = (JarTestSourceMojo) lookupMojo(
"test-jar", testPom );
+ TestSourceJarMojo mojo = (TestSourceJarMojo) lookupMojo(
"test-jar", testPom );
mojo.execute();
}
catch ( Exception e )
@@ -149,7 +152,7 @@
try
{
- JarTestSourceMojo mojo = (JarTestSourceMojo) lookupMojo(
"test-jar", testPom );
+ TestSourceJarMojo mojo = (TestSourceJarMojo) lookupMojo(
"test-jar", testPom );
mojo.execute();
}
catch ( Exception e )
Modified:
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/custom-configuration/custom-configuration-config.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/custom-configuration/custom-configuration-config.xml?view=diff&rev=496027&r1=496026&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/custom-configuration/custom-configuration-config.xml
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/custom-configuration/custom-configuration-config.xml
Sat Jan 13 19:36:16 2007
@@ -28,7 +28,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
+ <!--
<executedProject
implementation="org.apache.maven.plugin.source.stubs.CustomConfigurationMavenProjectStub"/>
+ -->
<project
implementation="org.apache.maven.plugin.source.stubs.CustomConfigurationMavenProjectStub"/>
<outputDirectory>${basedir}/target/test/unit/custom-configuration/target</outputDirectory>
<finalName>custom-configuration</finalName>
Modified:
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/default-configuration/default-configuration-config.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/default-configuration/default-configuration-config.xml?view=diff&rev=496027&r1=496026&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/default-configuration/default-configuration-config.xml
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/default-configuration/default-configuration-config.xml
Sat Jan 13 19:36:16 2007
@@ -29,7 +29,9 @@
<configuration>
<outputDirectory>${basedir}/target/test/unit/default-configuration/target</outputDirectory>
<finalName>default-configuration</finalName>
+ <!--
<executedProject
implementation="org.apache.maven.plugin.source.stubs.DefaultConfigurationMavenProjectStub"/>
+ -->
<project
implementation="org.apache.maven.plugin.source.stubs.DefaultConfigurationMavenProjectStub"/>
</configuration>
</plugin>
Modified:
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/invalid-packaging/invalid-packaging-config.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/invalid-packaging/invalid-packaging-config.xml?view=diff&rev=496027&r1=496026&r2=496027
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/invalid-packaging/invalid-packaging-config.xml
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/test/resources/unit/invalid-packaging/invalid-packaging-config.xml
Sat Jan 13 19:36:16 2007
@@ -28,7 +28,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
+ <!--
<executedProject
implementation="org.apache.maven.plugin.source.stubs.InvalidPackagingMavenProjectStub"/>
+ -->
<project
implementation="org.apache.maven.plugin.source.stubs.InvalidPackagingMavenProjectStub"/>
<outputDirectory>${basedir}/target/test/unit/invalid-packaging/target</outputDirectory>
<finalName>invalid-packaging</finalName>