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 2019/11/01 06:40:25 UTC
[karaf] branch karaf-4.2.x updated: [KARAF-6505] Allow override of
the bundle's dependency attribute (#984)
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
new 06bdf12 [KARAF-6505] Allow override of the bundle's dependency attribute (#984)
06bdf12 is described below
commit 06bdf12ff8441e45071c2558d86f1223f32ca43a
Author: Nelson Antunes <ne...@hitachivantara.com>
AuthorDate: Fri Nov 1 06:37:46 2019 +0000
[KARAF-6505] Allow override of the bundle's dependency attribute (#984)
[KARAF-6505] Override bundle's dependency attribute by specifying it in the feature descriptor
(cherry picked from commit 53e47855c8508b4e710255e3039896ca00758d6d)
---
.../developer-guide/karaf-maven-plugin.adoc | 9 ++++++++
.../it/test-transitive-as-dependency/control.xml | 1 +
.../src/it/test-transitive-as-dependency/pom.xml | 1 +
.../src/main/feature/feature.xml} | 9 +++-----
.../transitive-as-dependency-module-b/pom.xml | 5 +++++
.../pom.xml | 7 +-----
.../src/main/java/test/E.java | 25 ++++++++++++++++++++++
.../tooling/features/GenerateDescriptorMojo.java | 12 +++++------
8 files changed, 51 insertions(+), 18 deletions(-)
diff --git a/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc b/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc
index eb0aeb9..f47c9f7 100644
--- a/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc
+++ b/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc
@@ -187,6 +187,15 @@ This can be overridden by specifying the bundle in the source feature.xml with t
|overwriteChangedDependencies
|boolean (false)
|If true, the `src/main/history/dependencies.xml` file will be overwritten if it has changed.
+
+|markRuntimeScopeAsDependency
+|boolean (true)
+|Whether to mark dependencies' in the `runtime` scope with `dependency="true"`.
+
+|markTransitiveAsDependency
+|boolean (false)
+|Whether to mark transitive dependencies' with `dependency="true"`.
+|If true, the `src/main/history/dependencies.xml` file will be overwritten if it has changed.
|===
====== Example
diff --git a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/control.xml b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/control.xml
index 6ea9be2..3c20d56 100644
--- a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/control.xml
+++ b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/control.xml
@@ -20,6 +20,7 @@
<features xmlns="http://karaf.apache.org/xmlns/features/v1.6.0" name="transitive-as-dependency-feature">
<feature name="transitive-as-dependency-feature" description="transitive-as-dependency-feature" version="1.0.0.SNAPSHOT">
+ <bundle dependency="false">mvn:test/transitive-as-dependency-module-e/1.0-SNAPSHOT</bundle>
<bundle>mvn:test/transitive-as-dependency-module-a/1.0-SNAPSHOT</bundle>
<bundle>mvn:test/transitive-as-dependency-module-b/1.0-SNAPSHOT</bundle>
<bundle dependency="true">mvn:test/transitive-as-dependency-module-c/1.0-SNAPSHOT</bundle>
diff --git a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/pom.xml b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/pom.xml
index 75c74d6..3dde7c6 100644
--- a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/pom.xml
+++ b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/pom.xml
@@ -35,6 +35,7 @@
<module>transitive-as-dependency-module-b</module>
<module>transitive-as-dependency-module-c</module>
<module>transitive-as-dependency-module-d</module>
+ <module>transitive-as-dependency-module-e</module>
<module>transitive-as-dependency-feature</module>
</modules>
diff --git a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/control.xml b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-feature/src/main/feature/feature.xml
similarity index 64%
copy from tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/control.xml
copy to tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-feature/src/main/feature/feature.xml
index 6ea9be2..10b273d 100644
--- a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/control.xml
+++ b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-feature/src/main/feature/feature.xml
@@ -18,11 +18,8 @@
~ under the License.
-->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.6.0" name="transitive-as-dependency-feature">
- <feature name="transitive-as-dependency-feature" description="transitive-as-dependency-feature" version="1.0.0.SNAPSHOT">
- <bundle>mvn:test/transitive-as-dependency-module-a/1.0-SNAPSHOT</bundle>
- <bundle>mvn:test/transitive-as-dependency-module-b/1.0-SNAPSHOT</bundle>
- <bundle dependency="true">mvn:test/transitive-as-dependency-module-c/1.0-SNAPSHOT</bundle>
- <bundle dependency="true">mvn:test/transitive-as-dependency-module-d/1.0-SNAPSHOT</bundle>
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.6.0" name="${project.artifactId}">
+ <feature name="${project.artifactId}" description="${project.artifactId}" version="${project.version}">
+ <bundle dependency="false">mvn:test/transitive-as-dependency-module-e/1.0-SNAPSHOT</bundle>
</feature>
</features>
diff --git a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-b/pom.xml b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-b/pom.xml
index 3954a18..02f1ab1 100644
--- a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-b/pom.xml
+++ b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-b/pom.xml
@@ -44,6 +44,11 @@
<artifactId>transitive-as-dependency-module-c</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>test</groupId>
+ <artifactId>transitive-as-dependency-module-e</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
<build>
diff --git a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-b/pom.xml b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-e/pom.xml
similarity index 87%
copy from tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-b/pom.xml
copy to tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-e/pom.xml
index 3954a18..e463cd7 100644
--- a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-b/pom.xml
+++ b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-e/pom.xml
@@ -29,7 +29,7 @@
</parent>
<groupId>test</groupId>
- <artifactId>transitive-as-dependency-module-b</artifactId>
+ <artifactId>transitive-as-dependency-module-e</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
@@ -39,11 +39,6 @@
</properties>
<dependencies>
- <dependency>
- <groupId>test</groupId>
- <artifactId>transitive-as-dependency-module-c</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
</dependencies>
<build>
diff --git a/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-e/src/main/java/test/E.java b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-e/src/main/java/test/E.java
new file mode 100644
index 0000000..7014d09
--- /dev/null
+++ b/tooling/karaf-maven-plugin/src/it/test-transitive-as-dependency/transitive-as-dependency-module-e/src/main/java/test/E.java
@@ -0,0 +1,25 @@
+/*
+ * 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.e;
+
+public class E
+{
+ public static String ESTRING = "E-string";
+}
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 50926fe..f056ecb 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
@@ -540,13 +540,13 @@ public class GenerateDescriptorMojo extends MojoSupport {
if (!includedTransitively && (!"provided".equals(entry.getScope()) || !ignoreScopeProvided)) {
feature.getBundle().add(bundle);
}
- }
- if (
- (markRuntimeScopeAsDependency && "runtime".equals( entry.getScope() )) ||
- (markTransitiveAsDependency && entry.isTransitive())
- ) {
- bundle.setDependency(true);
+ if (
+ (markRuntimeScopeAsDependency && "runtime".equals( entry.getScope() )) ||
+ (markTransitiveAsDependency && entry.isTransitive())
+ ) {
+ bundle.setDependency(true);
+ }
}
if (startLevel != null && bundle.getStartLevel() == 0) {