Author: gcc
Date: Wed Aug 31 14:00:08 2011
New Revision: 1163623
URL: http://svn.apache.org/viewvc?rev=1163623&view=rev
Log:
ARIES-732
Added support for building .eba archives that don't contain any of the bundles
(they're purely a zip with an application manifest). A new configuration
element has been added.
To create an eba that contains no bundles, use the following:
<configuration>
<archiveContent>none</archiveContent>
</configuration>
To create an eba that contains only the application content bundles, use the
following:
<configuration>
<archiveContent>applicationContent</archiveContent>
</configuration>
To create an eba that contains the application content bundles and any
transitive dependency bundles, use the following:
<configuration>
<archiveContent>applicationContent</archiveContent>
</configuration>
The configuration element <useTransitiveDependencies/> is deprecated in favour
of <archiveContent/>.
Added:
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub5.java
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub6.java
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-content-bundles-only/
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-content-bundles-only/plugin-config.xml
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-no-bundles/
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-no-bundles/plugin-config.xml
Modified:
aries/trunk/eba-maven-plugin/pom.xml
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
Modified: aries/trunk/eba-maven-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/pom.xml?rev=1163623&r1=1163622&r2=1163623&view=diff
==============================================================================
--- aries/trunk/eba-maven-plugin/pom.xml (original)
+++ aries/trunk/eba-maven-plugin/pom.xml Wed Aug 31 14:00:08 2011
@@ -30,7 +30,7 @@ under the License.
</parent>
<artifactId>eba-maven-plugin</artifactId>
- <version>0.3.1-SNAPSHOT</version>
+ <version>0.4-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Aries Maven EBA Plugin</name>
Modified:
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
URL:
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java?rev=1163623&r1=1163622&r2=1163623&view=diff
==============================================================================
---
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
(original)
+++
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
Wed Aug 31 14:00:08 2011
@@ -70,7 +70,7 @@ public class EbaMojo
private static final String APPLICATION_EXPORTSERVICE =
"Application-ExportService";
private static final String APPLICATION_IMPORTSERVICE =
"Application-ImportService";
private static final String APPLICATION_USEBUNDLE = "Use-Bundle";
-
+
/**
* Coverter for maven pom values to OSGi manifest values (pulled in from
the maven-bundle-plugin)
*/
@@ -197,6 +197,16 @@ public class EbaMojo
*/
private boolean useTransitiveDependencies;
+ /**
+ * Define which bundles to include in the archive.
+ * none - no bundles are included
+ * applicationContent - direct dependencies go into the content
+ * all - direct and transitive dependencies go into the content
+ *
+ * @parameter expression="${archiveContent}"
default-value="applicationContent"
+ */
+ private String archiveContent;
+
private File buildDir;
@@ -213,6 +223,13 @@ public class EbaMojo
getLog().debug( "finalName[" + finalName + "]" );
getLog().debug( "generateManifest[" + generateManifest + "]" );
+ if (archiveContent == null) {
+ archiveContent = new String("applicationContent");
+ }
+
+ getLog().debug( "archiveContent[" + archiveContent + "]" );
+ getLog().info( "archiveContent[" + archiveContent + "]" );
+
zipArchiver.setIncludeEmptyDirs( includeEmptyDirs );
zipArchiver.setCompress( true );
zipArchiver.setForced( forceCreation );
@@ -236,20 +253,36 @@ public class EbaMojo
// Copy dependencies
try
{
- Set<Artifact> artifacts;
+ Set<Artifact> artifacts = null;
if (useTransitiveDependencies) {
- artifacts = project.getArtifacts();
+ // if use transitive is set (i.e. true) then we need to make
sure archiveContent does not contradict (i.e. is set
+ // to the same compatible value or is the default).
+ if ("none".equals(archiveContent)) {
+ throw new
MojoExecutionException("<useTransitiveDependencies/> and <archiveContent/>
incompatibly configured. <useTransitiveDependencies/> is deprecated in favor
of <archiveContent/>." );
+ }
+ else {
+ artifacts = project.getArtifacts();
+ }
} else {
- artifacts = project.getDependencyArtifacts();
+ // check that archiveContent is compatible
+ if ("applicationContent".equals(archiveContent)) {
+ artifacts = project.getDependencyArtifacts();
+ }
+ else {
+ // the only remaining options should be
applicationContent="none"
+ getLog().info("archiveContent=none: application arvhive
will not contain any bundles.");
+ }
}
- for (Artifact artifact : artifacts) {
+ if (artifacts != null) {
+ for (Artifact artifact : artifacts) {
- ScopeArtifactFilter filter = new
ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
- if (!artifact.isOptional() && filter.include(artifact)) {
- getLog().info("Copying artifact[" + artifact.getGroupId()
+ ", " + artifact.getId() + ", " +
- artifact.getScope() + "]");
- zipArchiver.addFile(artifact.getFile(),
artifact.getArtifactId() + "-" + artifact.getVersion() + "." +
(artifact.getType() == null ? "jar" : artifact.getType()));
- }
+ ScopeArtifactFilter filter = new
ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+ if (!artifact.isOptional() && filter.include(artifact)) {
+ getLog().info("Copying artifact[" +
artifact.getGroupId() + ", " + artifact.getId() + ", " +
+ artifact.getScope() + "]");
+ zipArchiver.addFile(artifact.getFile(),
artifact.getArtifactId() + "-" + artifact.getVersion() + "." +
(artifact.getType() == null ? "jar" : artifact.getType()));
+ }
+ }
}
}
catch ( ArchiverException e )
@@ -477,7 +510,7 @@ public class EbaMojo
throws IOException
{
if (applicationManifestFile == null) {
- throw new NullPointerException("application manifest file location
not set");
+ throw new NullPointerException("Application manifest file location
not set. Use <generateManifest>true</generateManifest> if you want it to be
generated.");
}
File appMfFile = applicationManifestFile;
if (appMfFile.exists()) {
Modified:
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
URL:
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java?rev=1163623&r1=1163622&r2=1163623&view=diff
==============================================================================
---
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
(original)
+++
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
Wed Aug 31 14:00:08 2011
@@ -281,6 +281,101 @@ public class EbaMojoTest
assertTrue("Found Use-Bundle:", foundUseBundle);
}
+
+ public void testArchiveContentConfigurationNoBundles()
+ throws Exception
+ {
+ File testPom = new File( getBasedir(),
+
"target/test-classes/unit/basic-eba-no-bundles/plugin-config.xml" );
+
+ EbaMojo mojo = ( EbaMojo ) lookupMojo( "eba", testPom );
+
+ assertNotNull( mojo );
+
+ String finalName = ( String ) getVariableValueFromObject( mojo,
"finalName" );
+
+ String workDir = ( String ) getVariableValueFromObject( mojo,
"workDirectory" );
+
+ String outputDir = ( String ) getVariableValueFromObject( mojo,
"outputDirectory" );
+
+ mojo.execute();
+
+
+ //check the generated eba file
+ File ebaFile = new File( outputDir, finalName + ".eba" );
+
+ assertTrue( ebaFile.exists() );
+
+ //expected files/directories inside the eba file
+ List expectedFiles = new ArrayList();
+
+ expectedFiles.add(
"META-INF/maven/org.apache.maven.test/maven-eba-test/pom.properties" );
+ expectedFiles.add(
"META-INF/maven/org.apache.maven.test/maven-eba-test/pom.xml" );
+ expectedFiles.add(
"META-INF/maven/org.apache.maven.test/maven-eba-test/" );
+ expectedFiles.add( "META-INF/maven/org.apache.maven.test/" );
+ expectedFiles.add( "META-INF/maven/" );
+ expectedFiles.add( "META-INF/APPLICATION.MF" );
+ expectedFiles.add( "META-INF/" );
+
+ ZipFile eba = new ZipFile( ebaFile );
+
+ Enumeration entries = eba.getEntries();
+
+ assertTrue( entries.hasMoreElements() );
+
+ int missing = getSizeOfExpectedFiles(entries, expectedFiles);
+ assertEquals("Missing files: " + expectedFiles, 0, missing);
+
+ }
+
+ public void testArchiveContentConfigurationApplicationContentBundles()
+ throws Exception
+ {
+ File testPom = new File( getBasedir(),
+
"target/test-classes/unit/basic-eba-content-bundles-only/plugin-config.xml" );
+
+ EbaMojo mojo = ( EbaMojo ) lookupMojo( "eba", testPom );
+
+ assertNotNull( mojo );
+
+ String finalName = ( String ) getVariableValueFromObject( mojo,
"finalName" );
+
+ String workDir = ( String ) getVariableValueFromObject( mojo,
"workDirectory" );
+
+ String outputDir = ( String ) getVariableValueFromObject( mojo,
"outputDirectory" );
+
+ mojo.execute();
+
+
+ //check the generated eba file
+ File ebaFile = new File( outputDir, finalName + ".eba" );
+
+ assertTrue( ebaFile.exists() );
+
+ //expected files/directories inside the eba file
+ List expectedFiles = new ArrayList();
+
+ expectedFiles.add(
"META-INF/maven/org.apache.maven.test/maven-eba-test/pom.properties" );
+ expectedFiles.add(
"META-INF/maven/org.apache.maven.test/maven-eba-test/pom.xml" );
+ expectedFiles.add(
"META-INF/maven/org.apache.maven.test/maven-eba-test/" );
+ expectedFiles.add( "META-INF/maven/org.apache.maven.test/" );
+ expectedFiles.add( "META-INF/maven/" );
+ expectedFiles.add( "META-INF/APPLICATION.MF" );
+ expectedFiles.add( "META-INF/" );
+ expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" );
+ expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" );
+
+ ZipFile eba = new ZipFile( ebaFile );
+
+ Enumeration entries = eba.getEntries();
+
+ assertTrue( entries.hasMoreElements() );
+
+ int missing = getSizeOfExpectedFiles(entries, expectedFiles);
+ assertEquals("Missing files: " + expectedFiles, 0, missing);
+
+ }
+
private int getSizeOfExpectedFiles( Enumeration entries, List
expectedFiles )
{
while( entries.hasMoreElements() )
Added:
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub5.java
URL:
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub5.java?rev=1163623&view=auto
==============================================================================
---
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub5.java
(added)
+++
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub5.java
Wed Aug 31 14:00:08 2011
@@ -0,0 +1,31 @@
+package org.apache.aries.plugin.eba.stubs;
+
+/*
+ * 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;
+
+public class EbaMavenProjectStub5
+ extends EbaMavenProjectStub
+{
+ public File getFile()
+ {
+ return new File( getBasedir(),
"src/test/resources/unit/basic-eba-no-bundles/plugin-config.xml" );
+ }
+}
Added:
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub6.java
URL:
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub6.java?rev=1163623&view=auto
==============================================================================
---
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub6.java
(added)
+++
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub6.java
Wed Aug 31 14:00:08 2011
@@ -0,0 +1,31 @@
+package org.apache.aries.plugin.eba.stubs;
+
+/*
+ * 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;
+
+public class EbaMavenProjectStub6
+ extends EbaMavenProjectStub
+{
+ public File getFile()
+ {
+ return new File( getBasedir(),
"src/test/resources/unit/basic-eba-content-bundles-only/plugin-config.xml" );
+ }
+}
Added:
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-content-bundles-only/plugin-config.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-content-bundles-only/plugin-config.xml?rev=1163623&view=auto
==============================================================================
---
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-content-bundles-only/plugin-config.xml
(added)
+++
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-content-bundles-only/plugin-config.xml
Wed Aug 31 14:00:08 2011
@@ -0,0 +1,38 @@
+<!-- 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. -->
+
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>eba-maven-plugin</artifactId>
+ <configuration>
+
<ebaSourceDirectory>${basedir}/src/test/resources/unit/basic-eba-content-bundles-only/src/main/eba</ebaSourceDirectory>
+
<generateManifest>true</generateManifest>
+
<archiveContent>applicationContent</archiveContent>
+ <instructions>
+ </instructions>
+ <includeJar>false</includeJar>
+
<addMavenDescriptor>true</addMavenDescriptor>
+
<includeEmptyDirs>true</includeEmptyDirs>
+
<workDirectory>${basedir}/target/unit/basic-eba-content-bundles-only/target/eba-test-content-bundles-only
+ </workDirectory>
+
<sharedResources>${basedir}/target/unit/basic-eba-content-bundles-only/target/maven-shared-archive-resources
+ </sharedResources>
+
<outputDirectory>${basedir}/target/unit/basic-eba-content-bundles-only/target
+ </outputDirectory>
+
<finalName>test-eba-content-bundles-only</finalName>
+ <project
implementation="org.apache.aries.plugin.eba.stubs.EbaMavenProjectStub6" />
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-no-bundles/plugin-config.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-no-bundles/plugin-config.xml?rev=1163623&view=auto
==============================================================================
---
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-no-bundles/plugin-config.xml
(added)
+++
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-no-bundles/plugin-config.xml
Wed Aug 31 14:00:08 2011
@@ -0,0 +1,38 @@
+<!-- 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. -->
+
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>eba-maven-plugin</artifactId>
+ <configuration>
+
<ebaSourceDirectory>${basedir}/src/test/resources/unit/basic-eba-no-bundles/src/main/eba</ebaSourceDirectory>
+
<generateManifest>true</generateManifest>
+ <archiveContent>none</archiveContent>
+ <instructions>
+ </instructions>
+ <includeJar>false</includeJar>
+
<addMavenDescriptor>true</addMavenDescriptor>
+
<includeEmptyDirs>true</includeEmptyDirs>
+
<workDirectory>${basedir}/target/unit/basic-eba-no-bundles/target/eba-test-no-bundles
+ </workDirectory>
+
<sharedResources>${basedir}/target/unit/basic-eba-no-bundles/target/maven-shared-archive-resources
+ </sharedResources>
+
<outputDirectory>${basedir}/target/unit/basic-eba-no-bundles/target
+ </outputDirectory>
+
<finalName>test-eba-no-bundles</finalName>
+ <project
implementation="org.apache.aries.plugin.eba.stubs.EbaMavenProjectStub5" />
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>