You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/06/21 07:51:33 UTC
svn commit: r415920 - in
/maven/shared/trunk/maven-archiver/src/main/java/org/apache/maven/archiver:
ManifestConfiguration.java MavenArchiver.java
Author: brett
Date: Tue Jun 20 22:51:32 2006
New Revision: 415920
URL: http://svn.apache.org/viewvc?rev=415920&view=rev
Log:
[MJAR-38, MWAR-34] make adding of default extension entries optional and default to false. Correct the values entered into some of them.
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/MavenArchiver.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=415920&r1=415919&r2=415920&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 Jun 20 22:51:32 2006
@@ -29,20 +29,24 @@
private String packageName;
+ private boolean addClasspath;
+
+ private boolean addExtensions;
+
/**
- * @todo boolean instead
+ * This gets prefixed to all classpath entries.
*/
- private String addClasspath;
+ private String classpathPrefix = "";
/**
- * @todo boolean instead
+ * Add default implementation entries if this is an extension specification.
*/
- private String addExtensions;
+ private boolean addDefaultSpecificationEntries;
/**
- * This gets prefixed to all classpath entries.
+ * Add default implementation entries if this is an extension.
*/
- private String classpathPrefix = "";
+ private boolean addDefaultImplementationEntries;
public String getMainClass()
{
@@ -51,12 +55,12 @@
public boolean isAddClasspath()
{
- return addClasspath != null ? Boolean.valueOf( addClasspath ).booleanValue() : false;
+ return addClasspath;
}
public boolean isAddExtensions()
{
- return addExtensions != null ? Boolean.valueOf( addExtensions ).booleanValue() : false;
+ return addExtensions;
}
public String getPackageName()
@@ -68,11 +72,21 @@
{
String cpp = classpathPrefix.replaceAll( "\\\\", "/" );
- if ( cpp.length() != 0 && !cpp.endsWith("/") )
+ if ( cpp.length() != 0 && !cpp.endsWith( "/" ) )
{
cpp += "/";
}
-
+
return cpp;
+ }
+
+ public boolean isAddDefaultImplementationEntries()
+ {
+ return addDefaultImplementationEntries;
+ }
+
+ public boolean isAddDefaultSpecificationEntries()
+ {
+ return addDefaultSpecificationEntries;
}
}
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=415920&r1=415919&r2=415920&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 Jun 20 22:51:32 2006
@@ -107,30 +107,13 @@
protected Manifest getManifest( MavenProject project, ManifestConfiguration config, Map entries )
throws ManifestException, DependencyResolutionRequiredException
{
- // Should we replace "map" with a copy? Note, that we modify it!
+ // TODO: Should we replace "map" with a copy? Note, that we modify it!
// Added basic entries
Manifest m = new Manifest();
- addManifestAttribute( m, entries, "Built-By", System.getProperty( "user.name" ) );
addManifestAttribute( m, entries, "Created-By", "Apache Maven" );
-/* 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() );
- }
-
- addManifestAttribute( m, entries, "Build-Jdk", System.getProperty( "java.version" ) );
+ addCustomEntries( m, entries, config );
if ( config.isAddClasspath() )
{
@@ -159,23 +142,27 @@
}
}
- // Added supplementary entries
- addManifestAttribute( m, entries, "Extension-Name", project.getArtifactId() );
-
- if ( project.getDescription() != null )
+ if ( config.isAddDefaultSpecificationEntries() )
{
- // NOTE This should probably be project.getName() but it remains for backwards compatability
- addManifestAttribute( m, entries, "Specification-Title", project.getDescription() );
+ addManifestAttribute( m, entries, "Specification-Title", project.getName() );
+ addManifestAttribute( m, entries, "Specification-Version", project.getVersion() );
+
+ if ( project.getOrganization() != null )
+ {
+ addManifestAttribute( m, entries, "Specification-Vendor", project.getOrganization().getName() );
+ }
}
- if ( project.getOrganization() != null )
+ if ( config.isAddDefaultImplementationEntries() )
{
- addManifestAttribute( m, entries, "Specification-Vendor", project.getOrganization().getName() );
- addManifestAttribute( m, entries, "Implementation-Vendor", project.getOrganization().getName() );
- }
+ addManifestAttribute( m, entries, "Implementation-Title", project.getName() );
+ addManifestAttribute( m, entries, "Implementation-Version", project.getVersion() );
- addManifestAttribute( m, entries, "Implementation-Title", project.getArtifactId() );
- addManifestAttribute( m, entries, "Implementation-Version", project.getVersion() );
+ if ( project.getOrganization() != null )
+ {
+ addManifestAttribute( m, entries, "Implementation-Vendor", project.getOrganization().getName() );
+ }
+ }
String mainClass = config.getMainClass();
if ( mainClass != null && !"".equals( mainClass ) )
@@ -186,24 +173,23 @@
// Added extensions
if ( config.isAddExtensions() )
{
+ // TODO: this is only for applets - should we distinguish them as a packaging?
StringBuffer extensionsList = new StringBuffer();
Set artifacts = project.getArtifacts();
for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
{
Artifact artifact = (Artifact) iter.next();
- if ( "test".equals( artifact.getScope() ) )
- {
- continue;
- }
- // TODO: type of ejb should be added too?
- if ( "jar".equals( artifact.getType() ) )
+ if ( !Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
{
- if ( extensionsList.length() > 0 )
+ if ( "jar".equals( artifact.getType() ) )
{
- extensionsList.append( " " );
+ if ( extensionsList.length() > 0 )
+ {
+ extensionsList.append( " " );
+ }
+ extensionsList.append( artifact.getArtifactId() );
}
- extensionsList.append( artifact.getArtifactId() );
}
}
@@ -214,6 +200,8 @@
for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
{
+ // TODO: the correct solution here would be to have an extension type, and to read
+ // the real extension values either from the artifact's manifest or some part of the POM
Artifact artifact = (Artifact) iter.next();
if ( "jar".equals( artifact.getType() ) )
{
@@ -224,7 +212,6 @@
if ( artifact.getRepository() != null )
{
- // TODO: is this correct
iname = artifact.getArtifactId() + "-Implementation-URL";
String url = artifact.getRepository().getUrl() + "/" + artifact.toString();
addManifestAttribute( m, entries, iname, url );
@@ -234,6 +221,29 @@
}
return m;
+ }
+
+ private void addCustomEntries( Manifest m, Map entries, ManifestConfiguration config )
+ throws ManifestException
+ {
+ 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 );
+ }
+
+*/
+ if ( config.getPackageName() != null )
+ {
+ addManifestAttribute( m, entries, "Package", config.getPackageName() );
+ }
}
public JarArchiver getArchiver()