Author: jbonofre
Date: Thu Mar 21 01:08:10 2013
New Revision: 1459114

URL: http://svn.apache.org/r1459114
Log:
[KARAF-2215] Fix artifact attachment for kar

Added:
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/pom.xml
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/verify.bsh
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/pom.xml
    
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/verify.bsh
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/pom.xml
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/verify.bsh
    karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/
    
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/pom.xml
    
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/verify.bsh
Modified:
    karaf/trunk/archetypes/kar/src/main/resources/archetype-resources/pom.xml
    
karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CreateKarMojo.java

Modified: 
karaf/trunk/archetypes/kar/src/main/resources/archetype-resources/pom.xml
URL: 
http://svn.apache.org/viewvc/karaf/trunk/archetypes/kar/src/main/resources/archetype-resources/pom.xml?rev=1459114&r1=1459113&r2=1459114&view=diff
==============================================================================
--- karaf/trunk/archetypes/kar/src/main/resources/archetype-resources/pom.xml 
(original)
+++ karaf/trunk/archetypes/kar/src/main/resources/archetype-resources/pom.xml 
Thu Mar 21 01:08:10 2013
@@ -23,7 +23,7 @@
     <groupId>${groupId}</groupId>
     <artifactId>${artifactId}</artifactId>
     <version>${version}</version>
-    <packaging>pom</packaging>
+    <packaging>kar</packaging>
 
     <name>${artifactId}-kar</name>
     <description>${artifactId} details</description>

Added: karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/pom.xml
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/pom.xml?rev=1459114&view=auto
==============================================================================
--- karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/pom.xml 
(added)
+++ karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/pom.xml 
Thu Mar 21 01:08:10 2013
@@ -0,0 +1,56 @@
+<?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-kar-classifier</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <version>@pom.version@</version>
+                <executions>
+                    <execution>
+                        <id>generate-features-file</id>
+                        <goals>
+                            <goal>features-generate-descriptor</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>features-create-kar</id>
+                        <goals>
+                            <goal>features-create-kar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>classy</classifier>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Added: 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/verify.bsh
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/verify.bsh?rev=1459114&view=auto
==============================================================================
--- 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/verify.bsh 
(added)
+++ 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-classifier/verify.bsh 
Thu Mar 21 01:08:10 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.*;
+import java.lang.*;
+
+// check that the kar archive has been pushed to the repository
+File generated = new File(localRepositoryPath, 
"test/test-kar-classifier/1.0-SNAPSHOT/test-kar-classifier-1.0-SNAPSHOT-classy.kar");
+if (generated.exists()) {
+    return true;
+}
+
+return false;
\ No newline at end of file

Added: 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/pom.xml
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/pom.xml?rev=1459114&view=auto
==============================================================================
--- 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/pom.xml 
(added)
+++ 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/pom.xml 
Thu Mar 21 01:08:10 2013
@@ -0,0 +1,82 @@
+<?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-kar-multiple-kars</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <version>@pom.version@</version>
+                <executions>
+                    <execution>
+                        <id>generate-features-file1</id>
+                        <goals>
+                            <goal>features-generate-descriptor</goal>
+                        </goals>
+                        <configuration>
+                            
<attachmentArtifactClassifier>feature1</attachmentArtifactClassifier>
+                            
<outputFile>${project.build.directory}/feature/feature1.xml</outputFile>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>generate-features-file2</id>
+                        <goals>
+                            <goal>features-generate-descriptor</goal>
+                        </goals>
+                        <configuration>
+                            
<attachmentArtifactClassifier>feature2</attachmentArtifactClassifier>
+                            
<outputFile>${project.build.directory}/feature/feature2.xml</outputFile>
+                        </configuration>
+                    </execution>
+
+                    <execution>
+                        <id>features-create-kar1</id>
+                        <goals>
+                            <goal>features-create-kar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>kar1</classifier>
+                            
<featuresFile>${project.build.directory}/feature/feature1.xml</featuresFile>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>features-create-kar2</id>
+                        <goals>
+                            <goal>features-create-kar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>kar2</classifier>
+                            
<featuresFile>${project.build.directory}/feature/feature2.xml</featuresFile>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Added: 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/verify.bsh
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/verify.bsh?rev=1459114&view=auto
==============================================================================
--- 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/verify.bsh 
(added)
+++ 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-multiple-kars/verify.bsh 
Thu Mar 21 01:08:10 2013
@@ -0,0 +1,34 @@
+/*
+ * 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.*;
+import java.lang.*;
+
+// check if the kar archives and features XMLs have been pushed to the 
repository
+File feature1 = new File(localRepositoryPath, 
"test/test-kar-multiple-kars/1.0-SNAPSHOT/test-kar-multiple-kars-1.0-SNAPSHOT-feature1.xml");
+File feature2 = new File(localRepositoryPath, 
"test/test-kar-multiple-kars/1.0-SNAPSHOT/test-kar-multiple-kars-1.0-SNAPSHOT-feature2.xml");
+
+File kar1 = new File(localRepositoryPath, 
"test/test-kar-multiple-kars/1.0-SNAPSHOT/test-kar-multiple-kars-1.0-SNAPSHOT-kar1.kar");
+File kar2 = new File(localRepositoryPath, 
"test/test-kar-multiple-kars/1.0-SNAPSHOT/test-kar-multiple-kars-1.0-SNAPSHOT-kar2.kar");
+
+if (feature1.exists() && feature2.exists()  &&  kar1.exists() && 
kar2.exists()) {
+    return true;
+}
+
+return false;
\ No newline at end of file

Added: karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/pom.xml
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/pom.xml?rev=1459114&view=auto
==============================================================================
--- karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/pom.xml 
(added)
+++ karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/pom.xml 
Thu Mar 21 01:08:10 2013
@@ -0,0 +1,40 @@
+<?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-kar-packaging</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>kar</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <version>@pom.version@</version>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Added: 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/verify.bsh
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/verify.bsh?rev=1459114&view=auto
==============================================================================
--- karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/verify.bsh 
(added)
+++ karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-packaging/verify.bsh 
Thu Mar 21 01:08:10 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.*;
+import java.lang.*;
+
+// check if the kar archive has been pushed to the repository
+File generated = new File(localRepositoryPath, 
"test/test-kar-packaging/1.0-SNAPSHOT/test-kar-packaging-1.0-SNAPSHOT.kar");
+if (generated.exists()) {
+    return true;
+}
+
+return false;
\ No newline at end of file

Added: 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/pom.xml
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/pom.xml?rev=1459114&view=auto
==============================================================================
--- 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/pom.xml
 (added)
+++ 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/pom.xml
 Thu Mar 21 01:08:10 2013
@@ -0,0 +1,54 @@
+<?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-kar-with-pom-packaging</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <version>@pom.version@</version>
+                <executions>
+                    <execution>
+                        <id>generate-features-file</id>
+                        <goals>
+                            <goal>features-generate-descriptor</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>features-create-kar</id>
+                        <goals>
+                            <goal>features-create-kar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Added: 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/verify.bsh
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/verify.bsh?rev=1459114&view=auto
==============================================================================
--- 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/verify.bsh
 (added)
+++ 
karaf/trunk/tooling/karaf-maven-plugin/src/it/test-kar-with-pom-packaging/verify.bsh
 Thu Mar 21 01:08:10 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.*;
+import java.lang.*;
+
+// check the kar archive was pushed to the repository
+File generated = new File(localRepositoryPath, 
"test/test-kar-with-pom-packaging/1.0-SNAPSHOT/test-kar-with-pom-packaging-1.0-SNAPSHOT.kar");
+if (generated.exists()) {
+    return true;
+}
+
+return false;
\ No newline at end of file

Modified: 
karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CreateKarMojo.java
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CreateKarMojo.java?rev=1459114&r1=1459113&r2=1459114&view=diff
==============================================================================
--- 
karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CreateKarMojo.java
 (original)
+++ 
karaf/trunk/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/CreateKarMojo.java
 Thu Mar 21 01:08:10 2013
@@ -90,6 +90,14 @@ public class CreateKarMojo extends MojoS
     private String finalName = null;
 
     /**
+     * Classifier to add to the artifact generated. If given, the artifact 
will be attached.
+     * If it's not given, it will merely be written to the output directory 
according to the finalName.
+     *
+     * @parameter
+     */
+    protected String classifier;
+
+    /**
      * Location of resources directory for additional content to include in 
the kar.
      * Note that it includes everything under classes so as to include 
maven-remote-resources
      *
@@ -123,8 +131,20 @@ public class CreateKarMojo extends MojoS
         // Build the archive
         File archive = createArchive(resources);
 
+        // if no classifier is specified and packaging is not kar, display a 
warning
+        // and attach artifact
+        if (classifier == null && 
!this.getProject().getPackaging().equals("kar")) {
+            this.getLog().warn("Your project should use the \"kar\" packaging 
or configure a \"classifier\" for kar attachment");
+            projectHelper.attachArtifact(getProject(), "kar", null, archive);
+            return;
+        }
+
         // Attach the generated archive for install/deploy
-        projectHelper.attachArtifact(project, "kar", null, archive);
+        if (classifier != null) {
+            projectHelper.attachArtifact(getProject(), "kar", classifier, 
archive);
+        } else {
+            getProject().getArtifact().setFile(archive);
+        }
     }
 
     /**
@@ -167,7 +187,7 @@ public class CreateKarMojo extends MojoS
      */
     private File createArchive(List<Artifact> bundles) throws 
MojoExecutionException {
         ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
-        File archiveFile = getArchiveFile(outputDirectory, finalName, null);
+        File archiveFile = getArchiveFile(outputDirectory, finalName, 
classifier);
 
         MavenArchiver archiver = new MavenArchiver();
         archiver.setArchiver(jarArchiver);


Reply via email to