You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2015/12/15 14:43:50 UTC

[2/2] karaf git commit: [KARAF-4198] Support m2e incremental builds

[KARAF-4198] Support m2e incremental builds


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

Branch: refs/heads/master
Commit: b9c42b5a3df4ed06aee6c126baf25deb8b989c14
Parents: efe5805
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Dec 15 14:13:50 2015 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Dec 15 14:13:50 2015 +0100

----------------------------------------------------------------------
 tooling/karaf-services-maven-plugin/pom.xml     |  6 ++++
 .../tracker/GenerateServiceMetadata.java        |  7 +++-
 .../META-INF/m2e/lifecycle-mapping-metadata.xml | 35 ++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/b9c42b5a/tooling/karaf-services-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/karaf-services-maven-plugin/pom.xml b/tooling/karaf-services-maven-plugin/pom.xml
index 0ed55f7..54dd992 100644
--- a/tooling/karaf-services-maven-plugin/pom.xml
+++ b/tooling/karaf-services-maven-plugin/pom.xml
@@ -89,6 +89,12 @@
             <version>2.6</version>
         </dependency>
         <dependency>
+            <groupId>org.sonatype.plexus</groupId>
+            <artifactId>plexus-build-api</artifactId>
+            <version>0.0.7</version>
+        </dependency>
+        
+        <dependency>
             <groupId>org.apache.karaf</groupId>
             <artifactId>org.apache.karaf.util</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/karaf/blob/b9c42b5a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
index c441a2e..203108d 100644
--- a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
+++ b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
@@ -37,6 +37,7 @@ import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
@@ -44,6 +45,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
 import org.apache.xbean.finder.ClassFinder;
 import org.osgi.framework.BundleActivator;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
 /**
  * Generates service requirement and capabilities for activators
@@ -75,6 +77,9 @@ public class GenerateServiceMetadata extends AbstractMojo {
      */
     @Parameter(defaultValue = "project")
     protected String classLoader;
+    
+    @Component
+    private BuildContext buildContext;
 
     public void execute() throws MojoExecutionException, MojoFailureException {
         try {
@@ -118,7 +123,7 @@ public class GenerateServiceMetadata extends AbstractMojo {
 
                 File file = new File(outputDirectory, "OSGI-INF/karaf-tracker/" + clazz.getName());
                 file.getParentFile().mkdirs();
-                try (OutputStream os = new FileOutputStream(file)) {
+                try (OutputStream os = buildContext.newFileOutputStream(file)) {
                     props.store(os, null);
                 }
                 addSourceDirectory = true;

http://git-wip-us.apache.org/repos/asf/karaf/blob/b9c42b5a/tooling/karaf-services-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
----------------------------------------------------------------------
diff --git a/tooling/karaf-services-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/tooling/karaf-services-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
new file mode 100644
index 0000000..70a1f9f
--- /dev/null
+++ b/tooling/karaf-services-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -0,0 +1,35 @@
+<?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.
+-->
+<lifecycleMappingMetadata>
+    <pluginExecutions>
+        <pluginExecution>
+            <pluginExecutionFilter>
+                <goals>
+                    <goal>service-metadata-generate</goal>
+                </goals>
+            </pluginExecutionFilter>
+            <action>
+                <execute>
+                    <runOnIncremental>true</runOnIncremental>
+                </execute>
+            </action>
+        </pluginExecution>
+    </pluginExecutions>
+</lifecycleMappingMetadata>
\ No newline at end of file