You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2014/10/03 16:19:23 UTC

[1/2] git commit: [KARAF-2961] When Maven project packaging is bundle, include project artifact in generate features XML in the karaf-maven-plugin

Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 4ee45a522 -> acc8299db


[KARAF-2961] When Maven project packaging is bundle, include project artifact in generate features XML in the karaf-maven-plugin


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/5013d7db
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/5013d7db
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/5013d7db

Branch: refs/heads/karaf-3.0.x
Commit: 5013d7db09e7dc15e4136dedf898c99c1b36dc82
Parents: 4ee45a5
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Fri Oct 3 14:16:49 2014 +0200
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Fri Oct 3 14:19:13 2014 +0200

----------------------------------------------------------------------
 .../test-include-project-artifact/control.xml   | 25 ++++++++
 .../it/test-include-project-artifact/pom.xml    | 60 ++++++++++++++++++++
 .../src/main/java/test/App.java                 | 30 ++++++++++
 .../it/test-include-project-artifact/verify.bsh | 35 ++++++++++++
 .../features/GenerateDescriptorMojo.java        | 17 ++++++
 5 files changed, 167 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/5013d7db/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml
new file mode 100644
index 0000000..d4db328
--- /dev/null
+++ b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="test-include-project-artifact">
+    <feature name="test-include-project-artifact" description="test-include-project-artifact" version="1.0.0.SNAPSHOT">
+        <bundle>mvn:test/test-include-project-artifact/1.0-SNAPSHOT</bundle>
+    </feature>
+</features>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/5013d7db/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/pom.xml b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/pom.xml
new file mode 100644
index 0000000..976e5c1
--- /dev/null
+++ b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>test</groupId>
+    <artifactId>test-include-project-artifact</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <version>@pom.version@</version>
+                <executions>
+                    <execution>
+                        <id>generate-features-file</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>features-generate-descriptor</goal>
+                        </goals>
+                        <configuration>
+                            <includeProjectArtifact>true</includeProjectArtifact>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/5013d7db/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/src/main/java/test/App.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/src/main/java/test/App.java b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/src/main/java/test/App.java
new file mode 100644
index 0000000..c95d245
--- /dev/null
+++ b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/src/main/java/test/App.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+package test;
+
+/**
+ * Hello world!
+ */
+public class App {
+
+    public static void main( String[] args ) {
+        System.out.println( "Hello World!" );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/5013d7db/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/verify.bsh
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/verify.bsh b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/verify.bsh
new file mode 100644
index 0000000..6af1a7c
--- /dev/null
+++ b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/verify.bsh
@@ -0,0 +1,35 @@
+/*
+ * 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 org.custommonkey.xmlunit.*;
+import java.io.*;
+import java.lang.*;
+
+Reader r = new FileReader(new File(basedir, "control.xml"));
+
+// load the features file pushed to the repository
+File generated = new File(basedir, "target/feature/feature.xml" );
+if (generated.exists()) {
+    try {
+        XMLAssert.assertXMLEqual(r, new FileReader(generated));
+        return true;
+    } catch (Throwable ignored) { }
+}
+
+return false;

http://git-wip-us.apache.org/repos/asf/karaf/blob/5013d7db/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
index b0211e6..4c491d3 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
@@ -184,6 +184,15 @@ public class GenerateDescriptorMojo extends AbstractLogEnabled implements Mojo {
      */
     private boolean ignoreScopeProvided;
 
+    /**
+     * Flag indicating whether the main project artifact should be included (<code>true</code>) or not (<code>false</code>).
+     * <p/>
+     * Assumes the main project artifact is a bundle and the feature will be attached alongside using <code>attachmentArtifactClassifier</code>.
+     *
+     * @parameter default-value="false"
+     */
+    private boolean includeProjectArtifact;
+
     // *************************************************
     // READ-ONLY MAVEN PLUGIN PARAMETERS
     // *************************************************
@@ -320,6 +329,14 @@ public class GenerateDescriptorMojo extends AbstractLogEnabled implements Mojo {
         if (project.getDescription() != null && feature.getDetails() == null) {
             feature.setDetails(project.getDescription());
         }
+        if (includeProjectArtifact) {
+            Bundle bundle = objectFactory.createBundle();
+            bundle.setLocation(this.dependencyHelper.artifactToMvn(project.getArtifact()));
+            if (startLevel != null) {
+                bundle.setStartLevel(startLevel);
+            }
+            feature.getBundle().add(bundle);
+        }
         for (Map.Entry<?, String> entry : localDependencies.entrySet()) {
             Object artifact = entry.getKey();
 


[2/2] git commit: [KARAF-2961] Fix karaf-maven-plugin itests

Posted by jb...@apache.org.
[KARAF-2961] Fix karaf-maven-plugin itests


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/acc8299d
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/acc8299d
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/acc8299d

Branch: refs/heads/karaf-3.0.x
Commit: acc8299db260b6d7d3bdeb0b02b296248c377348
Parents: 5013d7d
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Fri Oct 3 16:18:46 2014 +0200
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Fri Oct 3 16:18:46 2014 +0200

----------------------------------------------------------------------
 .../src/it/test-include-project-artifact/control.xml             | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/acc8299d/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml
index d4db328..c030079 100644
--- a/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml
+++ b/tooling/karaf-maven-plugin/src/it/test-include-project-artifact/control.xml
@@ -18,8 +18,8 @@
   ~ under the License.
   -->
 
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="test-include-project-artifact">
-    <feature name="test-include-project-artifact" description="test-include-project-artifact" version="1.0.0.SNAPSHOT">
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="test-include-project-artifact">
+    <feature name="test-include-project-artifact" description="test-include-project-artifact" version="1.0-SNAPSHOT">
         <bundle>mvn:test/test-include-project-artifact/1.0-SNAPSHOT</bundle>
     </feature>
 </features>
\ No newline at end of file