Author: vsiveton
Date: Sun May 25 05:10:51 2008
New Revision: 659972
URL: http://svn.apache.org/viewvc?rev=659972&view=rev
Log:
o improved readingness of the code
o no code change
Modified:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
Modified:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java?rev=659972&r1=659971&r2=659972&view=diff
==============================================================================
---
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
(original)
+++
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
Sun May 25 05:10:51 2008
@@ -158,48 +158,46 @@
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." );
+
+ return;
}
- else
- {
- Archiver archiver = createArchiver();
- for ( Iterator i = projects.iterator(); i.hasNext(); )
- {
- MavenProject subProject = getProject( (MavenProject) i.next()
);
+ Archiver archiver = createArchiver();
- if ( "pom".equals( subProject.getPackaging() ) )
- {
- continue;
- }
+ for ( Iterator i = projects.iterator(); i.hasNext(); )
+ {
+ MavenProject subProject = getProject( (MavenProject) i.next() );
- archiveProjectContent( subProject, archiver );
+ if ( "pom".equals( subProject.getPackaging() ) )
+ {
+ continue;
}
- File outputFile = new File( outputDirectory, finalName + "-" +
getClassifier() + ".jar" );
-
- try
- {
- archiver.setDestFile( outputFile );
+ archiveProjectContent( subProject, archiver );
+ }
- 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 );
- }
+ 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 );
- }
- else
- {
- getLog().info( "NOT adding java-sources to attached artifacts
list." );
- }
+ if ( attach )
+ {
+ projectHelper.attachArtifact( project, "java-source",
getClassifier(), outputFile );
+ }
+ else
+ {
+ getLog().info( "NOT adding java-sources to attached artifacts
list." );
}
}
@@ -225,63 +223,53 @@
File sourceDirectory = new File( resource.getDirectory() );
- if ( sourceDirectory.exists() )
+ if ( !sourceDirectory.exists() )
{
- List resourceIncludes = resource.getIncludes();
-
- String includes[];
+ continue;
+ }
- if ( resourceIncludes == null || resourceIncludes.size() == 0 )
- {
- includes = DEFAULT_INCLUDES;
- }
- else
- {
- includes = (String[]) resourceIncludes.toArray( new
String[resourceIncludes.size()] );
- }
+ List resourceIncludes = resource.getIncludes();
+ String includes[];
+ if ( resourceIncludes == null || resourceIncludes.size() == 0 )
+ {
+ includes = DEFAULT_INCLUDES;
+ }
+ else
+ {
+ includes = (String[]) resourceIncludes.toArray( new
String[resourceIncludes.size()] );
+ }
- List resourceExcludes = resource.getExcludes();
+ List resourceExcludes = resource.getExcludes();
+ String[] excludes;
- String[] excludes;
+ if ( resourceExcludes == null || resourceExcludes.size() == 0 )
+ {
+ excludes = FileUtils.getDefaultExcludes();
+ }
+ else
+ {
+ List allExcludes = new ArrayList();
+ allExcludes.addAll( FileUtils.getDefaultExcludesAsList() );
+ allExcludes.addAll( resourceExcludes );
+ excludes = (String[]) allExcludes.toArray( new
String[allExcludes.size()] );
+ }
- if ( resourceExcludes == null || resourceExcludes.size() == 0 )
- {
- excludes = FileUtils.getDefaultExcludes();
- }
- else
- {
- List allExcludes = new ArrayList();
- allExcludes.addAll( FileUtils.getDefaultExcludesAsList() );
- allExcludes.addAll( resourceExcludes );
- excludes = (String[]) allExcludes.toArray( new
String[allExcludes.size()] );
- }
- String targetPath = resource.getTargetPath();
- if ( targetPath != null )
- {
- if ( !targetPath.trim().endsWith( "/" ) )
- {
- targetPath += "/";
- }
- addDirectory( archiver, sourceDirectory, targetPath,
includes, excludes );
- }
- else
+ String targetPath = resource.getTargetPath();
+ if ( targetPath != null )
+ {
+ if ( !targetPath.trim().endsWith( "/" ) )
{
- addDirectory( archiver, sourceDirectory, includes,
excludes );
+ targetPath += "/";
}
+ addDirectory( archiver, sourceDirectory, targetPath, includes,
excludes );
+ }
+ else
+ {
+ addDirectory( archiver, sourceDirectory, includes, excludes );
}
}
}
- /**
- * Method to attach generated artifact to artifact list
- *
- * @param outputFile the artifact file to be attached
- * @param classifier
- */
- protected void attachArtifact( File outputFile, String classifier )
- {
- }
-
protected Archiver createArchiver()
throws MojoExecutionException
{