Author: davidb
Date: Wed Apr 9 13:30:45 2014
New Revision: 1585964
URL: http://svn.apache.org/r1585964
Log:
[ARIES-1165] esa-maven-bundle without packaging type "esa"
Patch applied on behalf on Markus Kuppe with many thanks!
This closes pull request #6.
PS. I did reformat some of the changed files as they contained inconsistent
tabs/spaces.
Added:
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub7.java
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/plugin-config.xml
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/target/
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/target/maven-esa-test-1.0-SNAPSHOT.jar
Modified:
aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
Modified:
aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java
URL:
http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java?rev=1585964&r1=1585963&r2=1585964&view=diff
==============================================================================
---
aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java
(original)
+++
aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java
Wed Apr 9 13:30:45 2014
@@ -21,7 +21,6 @@ package org.apache.aries.plugin.esa;
import org.apache.maven.archiver.PomPropertiesUtil;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -52,9 +51,9 @@ public class EsaMojo
extends AbstractMojo
{
- public enum EsaContent {none, all, content};
+ public enum EsaContent {none, all, content};
- public static final String SUBSYSTEM_MF_URI = "OSGI-INF/SUBSYSTEM.MF";
+ public static final String SUBSYSTEM_MF_URI = "OSGI-INF/SUBSYSTEM.MF";
private static final String[] DEFAULT_INCLUDES = {"**/**"};
@@ -212,7 +211,7 @@ public class EsaMojo
Set<Artifact> artifacts = null;
switch (EsaContent.valueOf(archiveContent)) {
case none:
- getLog().info("archiveContent=none: subsystem arvhive will not
contain any bundles.");
+ getLog().info("archiveContent=none: subsystem archive will not
contain any bundles.");
break;
case content:
// only include the direct dependencies in the archive
@@ -227,15 +226,27 @@ public class EsaMojo
}
if (artifacts != null) {
+ // Explicitly add self to bundle set (used when pom packaging
+ // type != "esa" AND a file is present (no point to add to
+ // zip archive without file)
+ final Artifact selfArtifact = project.getArtifact();
+ if (!"esa".equals(selfArtifact.getType()) &&
selfArtifact.getFile() != null) {
+ getLog().info("Explicitly adding artifact[" +
selfArtifact.getGroupId() + ", " + selfArtifact.getId() + ", " +
selfArtifact.getScope() + "]");
+ artifacts.add(project.getArtifact());
+ }
+
artifacts = selectArtifacts(artifacts);
+ int cnt = 0;
for (Artifact artifact : artifacts) {
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()));
+ cnt++;
}
}
+ getLog().info(String.format("Added %s artifacts to subsystem
subsystem archive.", cnt));
}
}
catch ( ArchiverException e )
@@ -415,12 +426,12 @@ public class EsaMojo
if (iter.hasNext()) {
Artifact artifact = iter.next();
String entry = new String(
-
maven2OsgiConverter.getBundleSymbolicName(artifact)
+ maven2OsgiConverter.getBundleSymbolicName(artifact)
+ ";version=\""
+ Analyzer.cleanupVersion(artifact.getVersion())
+ "\"");
if ("dependencies".equals(startOrder)) {
- entry += ";start-order=\"" + order + "\"";
+ entry += ";start-order=\"" + order + "\"";
}
FileUtils.fileAppend(fileName, entry);
}
@@ -433,7 +444,7 @@ public class EsaMojo
+ Analyzer.cleanupVersion(artifact.getVersion())
+ "\"");
if ("dependencies".equals(startOrder)) {
- entry += ";start-order=\"" + order + "\"";
+ entry += ";start-order=\"" + order + "\"";
}
FileUtils.fileAppend(fileName, entry);
}
Modified:
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
URL:
http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java?rev=1585964&r1=1585963&r2=1585964&view=diff
==============================================================================
---
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
(original)
+++
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
Wed Apr 9 13:30:45 2014
@@ -52,8 +52,20 @@ public class EsaMojoTest
public void testBasicEsa()
throws Exception
{
+ testBasicEsa(
"target/test-classes/unit/basic-esa-test/plugin-config.xml", null );
+ }
+
+ public void testBasicEsaPgkType()
+ throws Exception
+ {
+ testBasicEsa(
"target/test-classes/unit/basic-esa-test-with-pgk-type/plugin-config.xml",
"maven-esa-test-1.0-SNAPSHOT.jar" );
+ }
+
+ private void testBasicEsa(String path, String extraExpectedFiles)
+ throws Exception
+ {
File testPom = new File( getBasedir(),
-
"target/test-classes/unit/basic-esa-test/plugin-config.xml" );
+ path );
EsaMojo mojo = ( EsaMojo ) lookupMojo( "esa", testPom );
@@ -83,6 +95,10 @@ public class EsaMojoTest
expectedFiles.add( "META-INF/" );
expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" );
expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" );
+ if (extraExpectedFiles != null)
+ {
+ expectedFiles.add( extraExpectedFiles );
+ }
ZipFile esa = new ZipFile( esaFile );
Added:
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub7.java
URL:
http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub7.java?rev=1585964&view=auto
==============================================================================
---
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub7.java
(added)
+++
aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub7.java
Wed Apr 9 13:30:45 2014
@@ -0,0 +1,43 @@
+package org.apache.aries.plugin.esa.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;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+
+public class EsaMavenProjectStub7
+ extends EsaMavenProjectStub
+{
+ public File getFile()
+ {
+ return new File( getBasedir(),
"src/test/resources/unit/basic-esa-test-with-pgk-type/plugin-config.xml" );
+ }
+
+ @Override
+ public Artifact getArtifact()
+ {
+ ArtifactStub artfct = (ArtifactStub) super.getArtifact();
+ artfct.setFile( new File( getBasedir(),
"src/test/resources/unit/basic-esa-test-with-pgk-type/target/maven-esa-test-1.0-SNAPSHOT.jar"
) );
+ artfct.setType( "jar" );
+ return artfct;
+ }
+}
Added:
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/plugin-config.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/plugin-config.xml?rev=1585964&view=auto
==============================================================================
---
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/plugin-config.xml
(added)
+++
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/plugin-config.xml
Wed Apr 9 13:30:45 2014
@@ -0,0 +1,40 @@
+<!--
+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>esa-maven-plugin</artifactId>
+ <configuration>
+
<esaSourceDirectory>${basedir}/src/test/resources/unit/basic-esa-test-with-pgk-type/src/main/esa</esaSourceDirectory>
+
<subsystemManifestFile>${basedir}/src/test/resources/unit/basic-esa-test-with-pgk-type/src/main/esa/OSGI-INF/SUBSYSTEM.MF</subsystemManifestFile>
+ <addMavenDescriptor>true</addMavenDescriptor>
+ <includeEmptyDirs>true</includeEmptyDirs>
+
<manifestFile>${basedir}/src/main/esa/META-INF/MANIFEST.MF</manifestFile>
+
<workDirectory>${basedir}/target/unit/basic-esa-test-with-pgk-type/target/esa-test</workDirectory>
+
<sharedResources>${basedir}/target/unit/basic-esa-test-with-pgk-type/target/maven-shared-archive-resources</sharedResources>
+
<outputDirectory>${basedir}/target/unit/basic-esa-test-with-pgk-type/target</outputDirectory>
+ <finalName>test-esa</finalName>
+ <project
implementation="org.apache.aries.plugin.esa.stubs.EsaMavenProjectStub7" />
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/target/maven-esa-test-1.0-SNAPSHOT.jar
URL:
http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/target/maven-esa-test-1.0-SNAPSHOT.jar?rev=1585964&view=auto
==============================================================================
---
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/target/maven-esa-test-1.0-SNAPSHOT.jar
(added)
+++
aries/trunk/esa-maven-plugin/src/test/resources/unit/basic-esa-test-with-pgk-type/target/maven-esa-test-1.0-SNAPSHOT.jar
Wed Apr 9 13:30:45 2014
@@ -0,0 +1 @@
+This is not an actual jar
\ No newline at end of file