You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2014/10/28 22:01:38 UTC
svn commit: r1634984 - in
/maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver:
ManifestConfiguration.java ManifestSection.java
MavenArchiveConfiguration.java MavenArchiver.java PomPropertiesUtil.java
Author: khmarbaise
Date: Tue Oct 28 21:01:38 2014
New Revision: 1634984
URL: http://svn.apache.org/r1634984
Log:
[MSHARED-380]
- Fixed several checkstyle reported errors/warnings.
Modified:
maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java
maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestSection.java
maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
Modified: maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java?rev=1634984&r1=1634983&r2=1634984&view=diff
==============================================================================
--- maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java (original)
+++ maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java Tue Oct 28 21:01:38 2014
@@ -1,8 +1,5 @@
package org.apache.maven.archiver;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -31,10 +28,19 @@ import org.apache.maven.artifact.handler
*/
public class ManifestConfiguration
{
+ /**
+ * The simple layout.
+ */
public static final String CLASSPATH_LAYOUT_TYPE_SIMPLE = "simple";
+ /**
+ * The layout type
+ */
public static final String CLASSPATH_LAYOUT_TYPE_REPOSITORY = "repository";
+ /**
+ * custom layout type.
+ */
public static final String CLASSPATH_LAYOUT_TYPE_CUSTOM = "custom";
private String mainClass;
@@ -63,47 +69,65 @@ public class ManifestConfiguration
* @since 2.1
*/
private boolean addDefaultImplementationEntries;
-
+
/**
- * The generated Class-Path entry will contains paths that follow the
- * Maven 2 repository layout:
+ * The generated Class-Path entry will contains paths that follow the Maven 2 repository layout:
* $groupId[0]/../${groupId[n]/$artifactId/$version/{fileName}
+ *
* @since 2.3
* @deprecated Use {@link ManifestConfiguration#classpathLayoutType} instead.
*/
private boolean classpathMavenRepositoryLayout = false;
-
+
private String classpathLayoutType = CLASSPATH_LAYOUT_TYPE_SIMPLE;
-
+
private String customClasspathLayout;
-
+
private boolean useUniqueVersions = true;
+ /**
+ * @return mainClass
+ */
public String getMainClass()
{
return mainClass;
}
+ /**
+ * @return the package name.
+ */
public String getPackageName()
{
return packageName;
}
+ /**
+ * @return if addClasspath true or false.
+ */
public boolean isAddClasspath()
{
return addClasspath;
}
+ /**
+ * @return {@link #addDefaultImplementationEntries}
+ */
public boolean isAddDefaultImplementationEntries()
{
return addDefaultImplementationEntries;
}
+ /**
+ * @return {@link #addDefaultSpecificationEntries}
+ */
public boolean isAddDefaultSpecificationEntries()
{
return addDefaultSpecificationEntries;
}
+ /**
+ * @return {@link #addExtensions}
+ */
public boolean isAddExtensions()
{
return addExtensions;
@@ -111,28 +135,42 @@ public class ManifestConfiguration
/**
* @deprecated Use {@link ManifestConfiguration#getClasspathLayoutType()}, and compare to
- * CLASSPATH_LAYOUT_TYPE_SIMPLE or CLASSPATH_LAYOUT_TYPE_REPOSITORY, also declared in {@link ManifestConfiguration}.
+ * CLASSPATH_LAYOUT_TYPE_SIMPLE or CLASSPATH_LAYOUT_TYPE_REPOSITORY, also declared in
+ * {@link ManifestConfiguration}.
+ * @return The state of classpath Maven repository layout.
*/
public boolean isClasspathMavenRepositoryLayout()
{
return classpathMavenRepositoryLayout;
}
+ /**
+ * @param addClasspath turn on addClasspath or off.
+ */
public void setAddClasspath( boolean addClasspath )
{
this.addClasspath = addClasspath;
}
+ /**
+ * @param addDefaultImplementationEntries true to add default implementations false otherwise.
+ */
public void setAddDefaultImplementationEntries( boolean addDefaultImplementationEntries )
{
this.addDefaultImplementationEntries = addDefaultImplementationEntries;
}
+ /**
+ * @param addDefaultSpecificationEntries add default specifications true/false.
+ */
public void setAddDefaultSpecificationEntries( boolean addDefaultSpecificationEntries )
{
this.addDefaultSpecificationEntries = addDefaultSpecificationEntries;
}
+ /**
+ * @param addExtensions true to add extensions false otherwise.
+ */
public void setAddExtensions( boolean addExtensions )
{
this.addExtensions = addExtensions;
@@ -140,29 +178,42 @@ public class ManifestConfiguration
/**
* @deprecated Use {@link ManifestConfiguration#setClasspathLayoutType(String)}, and use
- * CLASSPATH_LAYOUT_TYPE_SIMPLE, CLASSPATH_LAYOUT_TYPE_CUSTOM, or CLASSPATH_LAYOUT_TYPE_REPOSITORY,
- * also declared in {@link ManifestConfiguration}.
+ * CLASSPATH_LAYOUT_TYPE_SIMPLE, CLASSPATH_LAYOUT_TYPE_CUSTOM, or CLASSPATH_LAYOUT_TYPE_REPOSITORY, also
+ * declared in {@link ManifestConfiguration}.
+ * @param classpathMavenRepositoryLayout true/false classpath maven repository
*/
public void setClasspathMavenRepositoryLayout( boolean classpathMavenRepositoryLayout )
{
this.classpathMavenRepositoryLayout = classpathMavenRepositoryLayout;
}
+ /**
+ * @param classpathPrefix The prefix.
+ */
public void setClasspathPrefix( String classpathPrefix )
{
this.classpathPrefix = classpathPrefix;
}
+ /**
+ * @param mainClass The main class.
+ */
public void setMainClass( String mainClass )
{
this.mainClass = mainClass;
}
+ /**
+ * @param packageName The package name.
+ */
public void setPackageName( String packageName )
{
this.packageName = packageName;
}
+ /**
+ * @return The classpath prefix.
+ */
public String getClasspathPrefix()
{
String cpp = classpathPrefix.replaceAll( "\\\\", "/" );
@@ -176,28 +227,30 @@ public class ManifestConfiguration
}
/**
- * Return the type of layout to use when formatting classpath entries.
- * Default is taken from the constant CLASSPATH_LAYOUT_TYPE_SIMPLE, declared
- * in this class, which has a value of 'simple'. Other values are: 'repository'
- * (CLASSPATH_LAYOUT_TYPE_REPOSITORY, or the same as a maven classpath layout),
- * and 'custom' (CLASSPATH_LAYOUT_TYPE_CUSTOM).
- * <br/>
- * <b>NOTE:</b> If you specify a type of 'custom' you MUST set {@link ManifestConfiguration#setCustomClasspathLayout(String)}.
+ * Return the type of layout to use when formatting classpath entries. Default is taken from the constant
+ * CLASSPATH_LAYOUT_TYPE_SIMPLE, declared in this class, which has a value of 'simple'. Other values are:
+ * 'repository' (CLASSPATH_LAYOUT_TYPE_REPOSITORY, or the same as a maven classpath layout), and 'custom'
+ * (CLASSPATH_LAYOUT_TYPE_CUSTOM). <br/>
+ * <b>NOTE:</b> If you specify a type of 'custom' you MUST set
+ * {@link ManifestConfiguration#setCustomClasspathLayout(String)}.
+ * @return The classpath layout type.
*/
public String getClasspathLayoutType()
{
+ // CHECKSTYLE_OFF: LineLength
return CLASSPATH_LAYOUT_TYPE_SIMPLE.equals( classpathLayoutType ) && classpathMavenRepositoryLayout ? CLASSPATH_LAYOUT_TYPE_REPOSITORY
: classpathLayoutType;
+ // CHECKSTYLE_ON: LineLength
}
/**
- * Set the type of layout to use when formatting classpath entries.
- * Should be one of: 'simple' (CLASSPATH_LAYOUT_TYPE_SIMPLE), 'repository'
- * (CLASSPATH_LAYOUT_TYPE_REPOSITORY, or the same as a maven classpath layout),
- * and 'custom' (CLASSPATH_LAYOUT_TYPE_CUSTOM). The constant names noted here
- * are defined in the {@link ManifestConfiguration} class.
- * <br/>
- * <b>NOTE:</b> If you specify a type of 'custom' you MUST set {@link ManifestConfiguration#setCustomClasspathLayout(String)}.
+ * Set the type of layout to use when formatting classpath entries. Should be one of: 'simple'
+ * (CLASSPATH_LAYOUT_TYPE_SIMPLE), 'repository' (CLASSPATH_LAYOUT_TYPE_REPOSITORY, or the same as a maven classpath
+ * layout), and 'custom' (CLASSPATH_LAYOUT_TYPE_CUSTOM). The constant names noted here are defined in the
+ * {@link ManifestConfiguration} class. <br/>
+ * <b>NOTE:</b> If you specify a type of 'custom' you MUST set
+ * {@link ManifestConfiguration#setCustomClasspathLayout(String)}.
+ * @param classpathLayoutType The classpath layout type.
*/
public void setClasspathLayoutType( String classpathLayoutType )
{
@@ -205,15 +258,16 @@ public class ManifestConfiguration
}
/**
- * Retrieve the layout expression for use when the layout type set in {@link ManifestConfiguration#setClasspathLayoutType(String)}
- * has the value 'custom'. <b>The default value is null.</b>
- * Expressions will be evaluated against the following ordered list of classpath-related objects:
+ * Retrieve the layout expression for use when the layout type set in
+ * {@link ManifestConfiguration#setClasspathLayoutType(String)} has the value 'custom'. <b>The default value is
+ * null.</b> Expressions will be evaluated against the following ordered list of classpath-related objects:
* <ol>
- * <li>The current {@link Artifact} instance, if one exists.</li>
- * <li>The current {@link ArtifactHandler} instance from the artifact above.</li>
+ * <li>The current {@link Artifact} instance, if one exists.</li>
+ * <li>The current {@link ArtifactHandler} instance from the artifact above.</li>
* </ol>
* <br/>
* <b>NOTE:</b> If you specify a layout type of 'custom' you MUST set this layout expression.
+ * @return The custom classpath layout.
*/
public String getCustomClasspathLayout()
{
@@ -221,14 +275,16 @@ public class ManifestConfiguration
}
/**
- * Set the layout expression for use when the layout type set in {@link ManifestConfiguration#setClasspathLayoutType(String)}
- * has the value 'custom'. Expressions will be evaluated against the following ordered list of classpath-related objects:
+ * Set the layout expression for use when the layout type set in
+ * {@link ManifestConfiguration#setClasspathLayoutType(String)} has the value 'custom'. Expressions will be
+ * evaluated against the following ordered list of classpath-related objects:
* <ol>
- * <li>The current {@link Artifact} instance, if one exists.</li>
- * <li>The current {@link ArtifactHandler} instance from the artifact above.</li>
+ * <li>The current {@link Artifact} instance, if one exists.</li>
+ * <li>The current {@link ArtifactHandler} instance from the artifact above.</li>
* </ol>
* <br/>
* <b>NOTE:</b> If you specify a layout type of 'custom' you MUST set this layout expression.
+ * @param customClasspathLayout The custom classpath layout.
*/
public void setCustomClasspathLayout( String customClasspathLayout )
{
@@ -236,14 +292,13 @@ public class ManifestConfiguration
}
/**
- * Retrieve the flag for whether snapshot artifacts should be added to the
- * classpath using the timestamp/buildnumber version (the default, when this
- * flag is true), or using the generic -SNAPSHOT version (when the flag is
- * false).
- * <br/>
- * <b>NOTE:</b> If the snapshot was installed locally, this flag will not
- * have an effect on that artifact's inclusion, since it will have the same
- * version either way (i.e. -SNAPSHOT naming).
+ * Retrieve the flag for whether snapshot artifacts should be added to the classpath using the
+ * timestamp/buildnumber version (the default, when this flag is true), or using the generic
+ * -SNAPSHOT version (when the flag is false). <br/>
+ * <b>NOTE:</b> If the snapshot was installed locally, this flag will not have an effect on
+ * that artifact's inclusion, since it will have the same version either way (i.e. -SNAPSHOT naming).
+ *
+ * @return The state of {@link #useUniqueVersions}
*/
public boolean isUseUniqueVersions()
{
@@ -251,14 +306,12 @@ public class ManifestConfiguration
}
/**
- * Set the flag for whether snapshot artifacts should be added to the
- * classpath using the timestamp/buildnumber version (the default, when this
- * flag is true), or using the generic -SNAPSHOT version (when the flag is
- * false).
+ * Set the flag for whether snapshot artifacts should be added to the classpath using the timestamp/buildnumber
+ * version (the default, when this flag is true), or using the generic -SNAPSHOT version (when the flag is false).
* <br/>
- * <b>NOTE:</b> If the snapshot was installed locally, this flag will not
- * have an effect on that artifact's inclusion, since it will have the same
- * version either way (i.e. -SNAPSHOT naming).
+ * <b>NOTE:</b> If the snapshot was installed locally, this flag will not have an effect on that artifact's
+ * inclusion, since it will have the same version either way (i.e. -SNAPSHOT naming).
+ * @param useUniqueVersions true to use unique versions or not.
*/
public void setUseUniqueVersions( boolean useUniqueVersions )
{
Modified: maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestSection.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestSection.java?rev=1634984&r1=1634983&r2=1634984&view=diff
==============================================================================
--- maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestSection.java (original)
+++ maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestSection.java Tue Oct 28 21:01:38 2014
@@ -23,41 +23,59 @@ import java.util.HashMap;
import java.util.Map;
/**
- *
* @version $Id$
*/
-public class ManifestSection
+public class ManifestSection
{
private String name = null;
- private Map<String,String> manifestEntries = new HashMap<String,String>();
+ private Map<String, String> manifestEntries = new HashMap<String, String>();
+ /**
+ * @param key The key of the manifest entry.
+ * @param value The appropriate value.
+ */
public void addManifestEntry( String key, String value )
{
manifestEntries.put( key, value );
}
- public Map<String,String> getManifestEntries()
+ /**
+ * @return The entries.
+ */
+ public Map<String, String> getManifestEntries()
{
return manifestEntries;
}
+ /**
+ * @return The name.
+ */
public String getName()
{
return name;
}
+ /**
+ * @param name the name.
+ */
public void setName( String name )
{
this.name = name;
}
- public void addManifestEntries( Map<String,String> map )
+ /**
+ * @param map The map to add.
+ */
+ public void addManifestEntries( Map<String, String> map )
{
manifestEntries.putAll( map );
}
+ /**
+ * @return true if empty false otherwise.
+ */
public boolean isManifestEntriesEmpty()
{
return manifestEntries.isEmpty();
Modified: maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java?rev=1634984&r1=1634983&r2=1634984&view=diff
==============================================================================
--- maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java (original)
+++ maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java Tue Oct 28 21:01:38 2014
@@ -60,36 +60,57 @@ public class MavenArchiveConfiguration
*/
private File pomPropertiesFile;
+ /**
+ * @return {@link #compress}
+ */
public boolean isCompress()
{
return compress;
}
+ /**
+ * @return {@link #recompressAddedZips}
+ */
public boolean isRecompressAddedZips()
{
return recompressAddedZips;
}
+ /**
+ * @param recompressAddedZips {@link #recompressAddedZips}
+ */
public void setRecompressAddedZips( boolean recompressAddedZips )
{
this.recompressAddedZips = recompressAddedZips;
}
+ /**
+ * @return {@link #index}
+ */
public boolean isIndex()
{
return index;
}
+ /**
+ * @return {@link #addMavenDescriptor}
+ */
public boolean isAddMavenDescriptor()
{
return addMavenDescriptor;
}
+ /**
+ * @return {@link #manifestFile}
+ */
public File getManifestFile()
{
return manifestFile;
}
+ /**
+ * @return {@link #manifest}
+ */
public ManifestConfiguration getManifest()
{
if ( manifest == null )
@@ -99,96 +120,142 @@ public class MavenArchiveConfiguration
return manifest;
}
+ /**
+ * @param compress set compress to true/false.
+ */
public void setCompress( boolean compress )
{
this.compress = compress;
}
+ /**
+ * @param index set index to true/false.
+ */
public void setIndex( boolean index )
{
this.index = index;
}
+ /**
+ * @param addMavenDescriptor activate to add maven descriptor or not.
+ */
public void setAddMavenDescriptor( boolean addMavenDescriptor )
{
this.addMavenDescriptor = addMavenDescriptor;
}
+ /**
+ * @param manifestFile The manifest file.
+ */
public void setManifestFile( File manifestFile )
{
this.manifestFile = manifestFile;
}
+ /**
+ * @param manifest {@link ManifestConfiguration}
+ */
public void setManifest( ManifestConfiguration manifest )
{
this.manifest = manifest;
}
+ /**
+ * @param key The key of the entry.
+ * @param value The value of the entry.
+ */
public void addManifestEntry( String key, String value )
{
manifestEntries.put( key, value );
}
- public void addManifestEntries( Map<String,String> map )
+ /**
+ * @param map The whole map which should be added.
+ */
+ public void addManifestEntries( Map<String, String> map )
{
manifestEntries.putAll( map );
}
+ /**
+ * @return are there entries true yes false otherwise.
+ */
public boolean isManifestEntriesEmpty()
{
return manifestEntries.isEmpty();
}
+ /**
+ * @return {@link #manifestEntries}
+ */
public Map<String, String> getManifestEntries()
{
return manifestEntries;
}
+ /**
+ * @param manifestEntries {@link #manifestEntries}
+ */
public void setManifestEntries( Map<String, String> manifestEntries )
{
this.manifestEntries = manifestEntries;
}
+ /**
+ * @param section {@link ManifestSection}
+ */
public void addManifestSection( ManifestSection section )
{
manifestSections.add( section );
}
+ /**
+ * @param list Added list of {@link ManifestSection}.
+ */
public void addManifestSections( List<ManifestSection> list )
{
manifestSections.addAll( list );
}
+ /**
+ * @return if manifestSections is empty or not.
+ */
public boolean isManifestSectionsEmpty()
{
return manifestSections.isEmpty();
}
+ /**
+ * @return {@link #manifestSections}
+ */
public List<ManifestSection> getManifestSections()
{
return manifestSections;
}
+ /**
+ * @param manifestSections set The list of {@link ManifestSection}.
+ */
public void setManifestSections( List<ManifestSection> manifestSections )
{
this.manifestSections = manifestSections;
}
/**
- * <p>Returns, whether recreating the archive is forced (default). Setting
- * this option to false means, that the archiver should compare the
- * timestamps of included files with the timestamp of the target archive
- * and rebuild the archive only, if the latter timestamp precedes the
- * former timestamps. Checking for timestamps will typically offer a
- * performance gain (in particular, if the following steps in a build
- * can be suppressed, if an archive isn't recrated) on the cost that
- * you get inaccurate results from time to time. In particular, removal
- * of source files won't be detected.</p>
- * <p>An archiver doesn't necessarily support checks for uptodate. If
- * so, setting this option to true will simply be ignored.</p>
+ * <p>
+ * Returns, whether recreating the archive is forced (default). Setting this option to false means, that the
+ * archiver should compare the timestamps of included files with the timestamp of the target archive and rebuild the
+ * archive only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically
+ * offer a performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't
+ * recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files
+ * won't be detected.
+ * </p>
+ * <p>
+ * An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be
+ * ignored.
+ * </p>
*
- * @return True, if the target archive should always be created; false
- * otherwise
+ * @return True, if the target archive should always be created; false otherwise
* @see #setForced(boolean)
*/
public boolean isForced()
@@ -197,20 +264,20 @@ public class MavenArchiveConfiguration
}
/**
- * <p>Sets, whether recreating the archive is forced (default). Setting
- * this option to false means, that the archiver should compare the
- * timestamps of included files with the timestamp of the target archive
- * and rebuild the archive only, if the latter timestamp precedes the
- * former timestamps. Checking for timestamps will typically offer a
- * performance gain (in particular, if the following steps in a build
- * can be suppressed, if an archive isn't recrated) on the cost that
- * you get inaccurate results from time to time. In particular, removal
- * of source files won't be detected.</p>
- * <p>An archiver doesn't necessarily support checks for uptodate. If
- * so, setting this option to true will simply be ignored.</p>
+ * <p>
+ * Sets, whether recreating the archive is forced (default). Setting this option to false means, that the archiver
+ * should compare the timestamps of included files with the timestamp of the target archive and rebuild the archive
+ * only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically offer a
+ * performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't
+ * recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files
+ * won't be detected.
+ * </p>
+ * <p>
+ * An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be
+ * ignored.
+ * </p>
*
- * @param forced True, if the target archive should always be created; false
- * otherwise
+ * @param forced True, if the target archive should always be created; false otherwise
* @see #isForced()
*/
public void setForced( boolean forced )
@@ -219,8 +286,7 @@ public class MavenArchiveConfiguration
}
/**
- * Returns the location of the "pom.properties" file.
- * May be null, in which case a default value is choosen.
+ * Returns the location of the "pom.properties" file. May be null, in which case a default value is choosen.
*
* @return "pom.properties" location or null.
*/
@@ -230,8 +296,7 @@ public class MavenArchiveConfiguration
}
/**
- * Sets the location of the "pom.properties" file.
- * May be null, in which case a default value is choosen.
+ * Sets the location of the "pom.properties" file. May be null, in which case a default value is choosen.
*
* @param pomPropertiesFile "pom.properties" location or null.
*/
Modified: maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java?rev=1634984&r1=1634983&r2=1634984&view=diff
==============================================================================
--- maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java (original)
+++ maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java Tue Oct 28 21:01:38 2014
@@ -50,22 +50,42 @@ import java.util.Set;
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
* @version $Revision$ $Date$
*/
+/**
+ * @author kama
+ *
+ */
+/**
+ * @author kama
+ *
+ */
public class MavenArchiver
{
+ /**
+ * The simply layout.
+ */
public static final String SIMPLE_LAYOUT =
"${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}";
- public static final String REPOSITORY_LAYOUT = "${artifact.groupIdPath}/${artifact.artifactId}/" +
- "${artifact.baseVersion}/${artifact.artifactId}-" +
- "${artifact.version}${dashClassifier?}.${artifact.extension}";
+ /**
+ * Repository layout.
+ */
+ public static final String REPOSITORY_LAYOUT = "${artifact.groupIdPath}/${artifact.artifactId}/"
+ + "${artifact.baseVersion}/${artifact.artifactId}-"
+ + "${artifact.version}${dashClassifier?}.${artifact.extension}";
+ /**
+ * simple layout non unique.
+ */
public static final String SIMPLE_LAYOUT_NONUNIQUE =
"${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}";
- public static final String REPOSITORY_LAYOUT_NONUNIQUE = "${artifact.groupIdPath}/${artifact.artifactId}/" +
- "${artifact.baseVersion}/${artifact.artifactId}-" +
- "${artifact.baseVersion}${dashClassifier?}.${artifact.extension}";
+ /**
+ * Repository layout non unique.
+ */
+ public static final String REPOSITORY_LAYOUT_NONUNIQUE = "${artifact.groupIdPath}/${artifact.artifactId}/"
+ + "${artifact.baseVersion}/${artifact.artifactId}-"
+ + "${artifact.baseVersion}${dashClassifier?}.${artifact.extension}";
private static final List<String> ARTIFACT_EXPRESSION_PREFIXES;
@@ -85,22 +105,28 @@ public class MavenArchiver
* Return a pre-configured manifest
*
* @param project the project
- * @param config the configuration to use
+ * @param config the configuration to use
* @return a manifest, clients are recommended to use java.util.jar.Manifest datatype.
- * @throws org.apache.maven.artifact.DependencyResolutionRequiredException
- * .
- * @throws org.codehaus.plexus.archiver.jar.ManifestException
- * .
+ * @throws org.apache.maven.artifact.DependencyResolutionRequiredException .
+ * @throws org.codehaus.plexus.archiver.jar.ManifestException .
* @todo Add user attributes list and user groups list
* @deprecated
*/
- @SuppressWarnings ("UnusedDeclaration")
+ @SuppressWarnings( "UnusedDeclaration" )
public Manifest getManifest( MavenProject project, MavenArchiveConfiguration config )
throws ManifestException, DependencyResolutionRequiredException
{
return getManifest( null, project, config );
}
+ /**
+ * @param session The Maven Session.
+ * @param project The Maven Project.
+ * @param config The MavenArchiveConfiguration
+ * @return The {@link Manifest}
+ * @throws ManifestException In case of a failure.
+ * @throws DependencyResolutionRequiredException Resolution failure.
+ */
public Manifest getManifest( MavenSession session, MavenProject project, MavenArchiveConfiguration config )
throws ManifestException, DependencyResolutionRequiredException
{
@@ -122,7 +148,7 @@ public class MavenArchiver
if ( key.equals( "Class-Path" ) && attr != null )
{
// Merge the user-supplied Class-Path value with the programmatically
- // generated Class-Path. Note that the user-supplied value goes first
+ // generated Class-Path. Note that the user-supplied value goes first
// so that resources there will override any in the standard Class-Path.
attr.setValue( value + " " + attr.getValue() );
}
@@ -165,6 +191,11 @@ public class MavenArchiver
* Return a pre-configured manifest
*
* @todo Add user attributes list and user groups list
+ * @param project {@link MavenProject}
+ * @param config {@link ManifestConfiguration}
+ * @return {@link Manifest}
+ * @throws ManifestException Manifest exception.
+ * @throws DependencyResolutionRequiredException Dependency resolution exception.
*/
public Manifest getManifest( MavenProject project, ManifestConfiguration config )
throws ManifestException, DependencyResolutionRequiredException
@@ -172,6 +203,14 @@ public class MavenArchiver
return getManifest( null, project, config, Collections.<String, String>emptyMap() );
}
+ /**
+ * @param mavenSession {@link MavenSession}
+ * @param project {@link MavenProject}
+ * @param config {@link ManifestConfiguration}
+ * @return {@link Manifest}
+ * @throws ManifestException The manifest exception.
+ * @throws DependencyResolutionRequiredException The dependency resolution required exception.
+ */
public Manifest getManifest( MavenSession mavenSession, MavenProject project, ManifestConfiguration config )
throws ManifestException, DependencyResolutionRequiredException
{
@@ -183,7 +222,7 @@ public class MavenArchiver
{
if ( map.containsKey( key ) )
{
- return; // The map value will be added later
+ return; // The map value will be added later
}
addManifestAttribute( manifest, key, value );
}
@@ -205,6 +244,15 @@ public class MavenArchiver
}
}
+ /**
+ * @param session {@link MavenSession}
+ * @param project {@link MavenProject}
+ * @param config {@link ManifestConfiguration}
+ * @param entries The entries.
+ * @return {@link Manifest}
+ * @throws ManifestException The manifest exception.
+ * @throws DependencyResolutionRequiredException The dependency resolution required exception.
+ */
protected Manifest getManifest( MavenSession session, MavenProject project, ManifestConfiguration config,
Map<String, String> entries )
throws ManifestException, DependencyResolutionRequiredException
@@ -221,7 +269,8 @@ public class MavenArchiver
{
StringBuilder classpath = new StringBuilder();
- @SuppressWarnings ("unchecked") List<String> artifacts = project.getRuntimeClasspathElements();
+ @SuppressWarnings( "unchecked" )
+ List<String> artifacts = project.getRuntimeClasspathElements();
String classpathPrefix = config.getClasspathPrefix();
String layoutType = config.getClasspathLayoutType();
String layout = config.getCustomClasspathLayout();
@@ -233,8 +282,8 @@ public class MavenArchiver
File f = new File( artifactFile );
if ( f.getAbsoluteFile().isFile() )
{
- @SuppressWarnings ("unchecked") Artifact artifact =
- findArtifactWithFile( project.getArtifacts(), f );
+ @SuppressWarnings( "unchecked" )
+ Artifact artifact = findArtifactWithFile( project.getArtifacts(), f );
if ( classpath.length() > 0 )
{
@@ -242,7 +291,8 @@ public class MavenArchiver
}
classpath.append( classpathPrefix );
- // NOTE: If the artifact or layout type (from config) is null, give up and use the file name by itself.
+ // NOTE: If the artifact or layout type (from config) is null, give up and use the file name by
+ // itself.
if ( artifact == null || layoutType == null )
{
classpath.append( f.getName() );
@@ -250,11 +300,12 @@ public class MavenArchiver
else
{
List<ValueSource> valueSources = new ArrayList<ValueSource>();
- valueSources.add(
- new PrefixedObjectValueSource( ARTIFACT_EXPRESSION_PREFIXES, artifact, true ) );
- valueSources.add( new PrefixedObjectValueSource( ARTIFACT_EXPRESSION_PREFIXES, artifact == null
- ? null
- : artifact.getArtifactHandler(), true ) );
+ valueSources.add( new PrefixedObjectValueSource( ARTIFACT_EXPRESSION_PREFIXES, artifact, true ) );
+ valueSources.add( new PrefixedObjectValueSource(
+ ARTIFACT_EXPRESSION_PREFIXES,
+ artifact == null ? null
+ : artifact.getArtifactHandler(),
+ true ) );
Properties extraExpressions = new Properties();
if ( artifact != null )
@@ -278,8 +329,8 @@ public class MavenArchiver
extraExpressions.setProperty( "dashClassifier?", "" );
}
}
- valueSources.add(
- new PrefixedPropertiesValueSource( ARTIFACT_EXPRESSION_PREFIXES, extraExpressions, true ) );
+ valueSources.add( new PrefixedPropertiesValueSource( ARTIFACT_EXPRESSION_PREFIXES,
+ extraExpressions, true ) );
for ( ValueSource vs : valueSources )
{
@@ -299,8 +350,8 @@ public class MavenArchiver
}
else
{
- classpath.append(
- interpolator.interpolate( SIMPLE_LAYOUT_NONUNIQUE, recursionInterceptor ) );
+ classpath.append( interpolator.interpolate( SIMPLE_LAYOUT_NONUNIQUE,
+ recursionInterceptor ) );
}
}
else if ( ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_REPOSITORY.equals( layoutType ) )
@@ -309,20 +360,20 @@ public class MavenArchiver
// here we must find the Artifact in the project Artifacts to generate the maven layout
if ( config.isUseUniqueVersions() )
{
- classpath.append(
- interpolator.interpolate( REPOSITORY_LAYOUT, recursionInterceptor ) );
+ classpath.append( interpolator.interpolate( REPOSITORY_LAYOUT, recursionInterceptor ) );
}
else
{
- classpath.append(
- interpolator.interpolate( REPOSITORY_LAYOUT_NONUNIQUE, recursionInterceptor ) );
+ classpath.append( interpolator.interpolate( REPOSITORY_LAYOUT_NONUNIQUE,
+ recursionInterceptor ) );
}
}
else if ( ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_CUSTOM.equals( layoutType ) )
{
if ( layout == null )
{
- throw new ManifestException( ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_CUSTOM
+ throw new ManifestException(
+ ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_CUSTOM
+ " layout type was declared, but custom layout expression was not specified. Check your <archive><manifest><customLayout/> element." );
}
@@ -331,13 +382,14 @@ public class MavenArchiver
else
{
throw new ManifestException( "Unknown classpath layout type: '" + layoutType
- + "'. Check your <archive><manifest><layoutType/> element." );
+ + "'. Check your <archive><manifest><layoutType/> element." );
}
}
catch ( InterpolationException e )
{
- ManifestException error = new ManifestException(
- "Error interpolating artifact path for classpath entry: " + e.getMessage() );
+ ManifestException error =
+ new ManifestException( "Error interpolating artifact path for classpath entry: "
+ + e.getMessage() );
error.initCause( e );
throw error;
@@ -401,7 +453,8 @@ public class MavenArchiver
{
// TODO: this is only for applets - should we distinguish them as a packaging?
StringBuilder extensionsList = new StringBuilder();
- @SuppressWarnings ("unchecked") Set<Artifact> artifacts = (Set<Artifact>) project.getArtifacts();
+ @SuppressWarnings( "unchecked" )
+ Set<Artifact> artifacts = (Set<Artifact>) project.getArtifacts();
for ( Artifact artifact : artifacts )
{
@@ -455,33 +508,36 @@ public class MavenArchiver
addManifestAttribute( m, entries, "Built-By", System.getProperty( "user.name" ) );
addManifestAttribute( m, entries, "Build-Jdk", System.getProperty( "java.version" ) );
-/* TODO: rethink this, it wasn't working
- Artifact projectArtifact = project.getArtifact();
-
- if ( projectArtifact.isSnapshot() )
- {
- Manifest.Attribute buildNumberAttr = new Manifest.Attribute( "Build-Number", "" +
- project.getSnapshotDeploymentBuildNumber() );
- m.addConfiguredAttribute( buildNumberAttr );
- }
-
-*/
+ /*
+ * TODO: rethink this, it wasn't working Artifact projectArtifact = project.getArtifact(); if (
+ * projectArtifact.isSnapshot() ) { Manifest.Attribute buildNumberAttr = new Manifest.Attribute( "Build-Number",
+ * "" + project.getSnapshotDeploymentBuildNumber() ); m.addConfiguredAttribute( buildNumberAttr ); }
+ */
if ( config.getPackageName() != null )
{
addManifestAttribute( m, entries, "Package", config.getPackageName() );
}
}
+ /**
+ * @return {@link JarArchiver}
+ */
public JarArchiver getArchiver()
{
return archiver;
}
+ /**
+ * @param archiver {@link JarArchiver}
+ */
public void setArchiver( JarArchiver archiver )
{
this.archiver = archiver;
}
+ /**
+ * @param outputFile Set output file.
+ */
public void setOutputFile( File outputFile )
{
archiveFile = outputFile;
@@ -489,14 +545,29 @@ public class MavenArchiver
/**
* @deprecated
+ * @param project {@link MavenProject}
+ * @param archiveConfiguration {@link MavenArchiveConfiguration}
+ * @throws ArchiverException Archiver Exception.
+ * @throws ManifestException Manifest Exception.
+ * @throws IOException IO Exception.
+ * @throws DependencyResolutionRequiredException Dependency resolution exception.
*/
- @SuppressWarnings ("JavaDoc")
+ @SuppressWarnings( "JavaDoc" )
public void createArchive( MavenProject project, MavenArchiveConfiguration archiveConfiguration )
throws ArchiverException, ManifestException, IOException, DependencyResolutionRequiredException
{
createArchive( null, project, archiveConfiguration );
}
+ /**
+ * @param session {@link MavenSession}
+ * @param project {@link MavenProject}
+ * @param archiveConfiguration {@link MavenArchiveConfiguration}
+ * @throws ArchiverException Archiver Exception.
+ * @throws ManifestException Manifest Exception.
+ * @throws IOException IO Exception.
+ * @throws DependencyResolutionRequiredException Dependency resolution exception.
+ */
public void createArchive( MavenSession session, MavenProject project,
MavenArchiveConfiguration archiveConfiguration )
throws ArchiverException, ManifestException, IOException, DependencyResolutionRequiredException
@@ -508,7 +579,7 @@ public class MavenArchiver
{
workingProject = (MavenProject) project.clone();
}
- catch (CloneNotSupportedException e)
+ catch ( CloneNotSupportedException e )
{
// Should never happen
throw new ArchiverException( "Failed to clone Maven project", e );
@@ -579,7 +650,8 @@ public class MavenArchiver
// make the archiver index the jars on the classpath, if we are adding that to the manifest
if ( archiveConfiguration.getManifest().isAddClasspath() )
{
- @SuppressWarnings ("unchecked") List<String> artifacts = project.getRuntimeClasspathElements();
+ @SuppressWarnings( "unchecked" )
+ List<String> artifacts = project.getRuntimeClasspathElements();
for ( String artifact : artifacts )
{
File f = new File( artifact );
@@ -591,7 +663,8 @@ public class MavenArchiver
if ( !archiveConfiguration.isForced() && archiver.isSupportingForced() )
{
// TODO Should issue a warning here, but how do we get a logger?
- // TODO getLog().warn( "Forced build is disabled, but disabling the forced mode isn't supported by the archiver." );
+ // TODO getLog().warn(
+ // "Forced build is disabled, but disabling the forced mode isn't supported by the archiver." );
}
// create archive
@@ -613,7 +686,6 @@ public class MavenArchiver
addManifestAttribute( m, entries, "Created-By", createdBy );
}
-
private Artifact findArtifactWithFile( Set<Artifact> artifacts, File file )
{
for ( Artifact artifact : artifacts )
Modified: maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java?rev=1634984&r1=1634983&r2=1634984&view=diff
==============================================================================
--- maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java (original)
+++ maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java Tue Oct 28 21:01:38 2014
@@ -32,10 +32,9 @@ import org.codehaus.plexus.archiver.Arch
import org.codehaus.plexus.archiver.ArchiverException;
import org.apache.maven.shared.utils.io.IOUtil;
-
/**
- * This class is responsible for creating the pom.properties
- * file.
+ * This class is responsible for creating the pom.properties file.
+ *
* @version $Id$
*/
public class PomPropertiesUtil
@@ -43,7 +42,7 @@ public class PomPropertiesUtil
private static final String GENERATED_BY_MAVEN = "Generated by Apache Maven";
private boolean sameContents( Properties props, File file )
- throws IOException
+ throws IOException
{
if ( !file.isFile() )
{
@@ -51,7 +50,7 @@ public class PomPropertiesUtil
}
Properties fileProps = new Properties();
InputStream istream = null;
- try
+ try
{
istream = new FileInputStream( file );
fileProps.load( istream );
@@ -69,16 +68,15 @@ public class PomPropertiesUtil
}
}
- private void createPropertyFile( Properties properties, File outputFile,
- boolean forceCreation )
+ private void createPropertyFile( Properties properties, File outputFile, boolean forceCreation )
throws IOException
{
File outputDir = outputFile.getParentFile();
- if ( outputDir != null && !outputDir.isDirectory() && !outputDir.mkdirs() )
+ if ( outputDir != null && !outputDir.isDirectory() && !outputDir.mkdirs() )
{
throw new IOException( "Failed to create directory: " + outputDir );
}
- if ( !forceCreation && sameContents( properties, outputFile ) )
+ if ( !forceCreation && sameContents( properties, outputFile ) )
{
return;
}
@@ -97,6 +95,12 @@ public class PomPropertiesUtil
/**
* Creates the pom.properties file.
+ * @param project {@link MavenProject}
+ * @param archiver {@link Archiver}
+ * @param pomPropertiesFile The pom properties file.
+ * @param forceCreation force creation true/flas.e
+ * @throws ArchiverException archiver exception.
+ * @throws IOException IO exception.
*/
public void createPomProperties( MavenProject project, Archiver archiver, File pomPropertiesFile,
boolean forceCreation )