http://git-wip-us.apache.org/repos/asf/camel/blob/03a7e99b/spring-boot-dm/camel-spring-boot-generator-bom/pom.xml ---------------------------------------------------------------------- diff --git a/spring-boot-dm/camel-spring-boot-generator-bom/pom.xml b/spring-boot-dm/camel-spring-boot-generator-bom/pom.xml index d5c4125..4a9f91f 100644 --- a/spring-boot-dm/camel-spring-boot-generator-bom/pom.xml +++ b/spring-boot-dm/camel-spring-boot-generator-bom/pom.xml @@ -1,4 +1,20 @@ <?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. +--> <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"> @@ -9,33 +25,39 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-spring-boot-bom-ng</artifactId> + <artifactId>camel-spring-boot-generator-bom</artifactId> <packaging>pom</packaging> + <name>Camel :: Spring-Boot :: Dependency Management :: BOM Generator</name> + <description>Camel Spring-Boot BOM Generator</description> <dependencyManagement> <dependencies> + <!-- + The dependency management is organized as follows: + - custom dependencies first (to override values) + - spring-boot dependencies + - camel dependencies + + Dependencies are flattened and a BOM file is generated using a plugin. + --> + + <!-- Use the camel version of caffeine --> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>${caffeine-version}</version> </dependency> - <!-- Missing from spring-boot --> + <!-- Added to match the version of related libraries provided by spring-boot --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate-version}</version> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit-version}</version> - </dependency> - - <!-- Choose a uniform jackson1 for testing --> + <!-- Add a uniform jackson 1 (used in many components) --> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core</artifactId> @@ -62,21 +84,21 @@ <version>${jackson-version}</version> </dependency> - <!-- Missing in spring-boot --> + <!-- Added to match the version of related libraries provided by spring-boot --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-ext</artifactId> <version>${slf4j-version}</version> </dependency> - <!-- Also missing --> + <!-- Added to match the version of related libraries provided by spring-boot --> <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna-platform</artifactId> <version>${jna-version}</version> </dependency> - <!-- Some are missing --> + <!-- Added to match the version of related libraries provided by spring-boot --> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-util-ajax</artifactId> @@ -84,30 +106,16 @@ </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-jmx</artifactId> - <version>${jetty-version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-security</artifactId> - <version>${jetty-version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-client</artifactId> - <version>${jetty-version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-rewrite</artifactId> <version>${jetty-version}</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-io</artifactId> + <artifactId>jetty-servlet</artifactId> <version>${jetty-version}</version> </dependency> - <!-- Jetty - Mismatch resolved in favour of spring-boot --> + + <!-- Added to match the version of related libraries provided by spring-boot --> <dependency> <groupId>org.eclipse.jetty.websocket</groupId> <artifactId>websocket-api</artifactId> @@ -128,19 +136,8 @@ <artifactId>websocket-servlet</artifactId> <version>${jetty-version}</version> </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - <version>${jetty-version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> - <version>${jetty-version}</version> - </dependency> - - <!-- ActiveMq from camel --> + <!-- Using the version of ActiveMQ from camel --> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-amqp</artifactId> @@ -295,7 +292,7 @@ <version>${activemq-version}</version> </dependency> - <!-- Missing in spring-boot --> + <!-- Added to match the version of related libraries provided by Camel --> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-scala_2.11</artifactId> @@ -307,7 +304,7 @@ <version>${jackson2-version}</version> </dependency> - <!-- Jackson From spring-boot --> + <!-- Using the Camel Version of Jackson --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> @@ -409,44 +406,8 @@ <version>${jackson2-version}</version> </dependency> - <!-- Spring dependencies (not included in spring-boot BOM) --> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-aop</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-tx</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context-support</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-oxm</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-jms</artifactId> - <version>${spring-version}</version> - </dependency> - + <!-- Dependencies from the spring-boot BOM are included after custom dependencies --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> @@ -455,6 +416,7 @@ <scope>import</scope> </dependency> + <!-- Dependencies from Camel parent at the end --> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-parent</artifactId> @@ -484,33 +446,32 @@ <configuration> <dependencies> <includes> - <include>org.apache.camel:*</include> - <include>org.springframework.boot:*</include> - - <include>com.github.ben-manes.caffeine:*</include> - <include>org.hibernate:*</include> - <include>junit:junit</include> - <include>org.codehaus.jackson:jackson*</include> - <include>org.slf4j:*</include> - <include>net.java.dev.jna:*</include> - - <include>org.eclipse.jetty:*</include> - <include>org.eclipse.jetty.websocket:*</include> + <include>*:*</include> + </includes> + <excludes> - <include>org.apache.activemq:*</include> + <!-- These artifacts should not be included in the final (generated) BOM --> - <include>com.fasterxml.jackson.*:*</include> + <exclude>com.google.inject:*</exclude> + <exclude>com.google.guava:*</exclude> + <exclude>com.google.code.gson:*</exclude> - <include>org.springframework:*</include> + <exclude>org.apache.servicemix.bundles:*</exclude> + <exclude>org.ops4j.pax*:*</exclude> + <exclude>org.codehaus.mojo:*</exclude> + <exclude>org.apache.servicemix:*</exclude> + <exclude>org.apache.aries.blueprint:*</exclude> + <exclude>org.apache.felix:*</exclude> + <exclude>org.apache.maven.archetype:*</exclude> + <exclude>org.osgi:*</exclude> - </includes> - <excludes> <exclude>org.springframework:springloaded</exclude> + <exclude>com.zaxxer:HikariCP-java6</exclude> </excludes> </dependencies> <sourcePom>${basedir}/target-template-pom.xml</sourcePom> - <targetPom>${basedir}/../camel-spring-boot-bom-ng/pom.xml</targetPom> + <targetPom>${basedir}/../camel-spring-boot-dependencies/pom.xml</targetPom> </configuration> </plugin>
http://git-wip-us.apache.org/repos/asf/camel/blob/03a7e99b/spring-boot-dm/camel-spring-boot-generator-bom/target-template-pom.xml ---------------------------------------------------------------------- diff --git a/spring-boot-dm/camel-spring-boot-generator-bom/target-template-pom.xml b/spring-boot-dm/camel-spring-boot-generator-bom/target-template-pom.xml index f1de6ac..276f09d 100644 --- a/spring-boot-dm/camel-spring-boot-generator-bom/target-template-pom.xml +++ b/spring-boot-dm/camel-spring-boot-generator-bom/target-template-pom.xml @@ -1,4 +1,20 @@ <?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. +--> <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"> @@ -9,7 +25,10 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-spring-boot-bom-ng</artifactId> + <artifactId>camel-spring-boot-dependencies</artifactId> + <packaging>pom</packaging> + <name>Camel :: Spring-Boot :: Dependency Management :: BOM</name> + <description>Camel Spring-Boot BOM</description> <dependencyManagement> <dependencies> http://git-wip-us.apache.org/repos/asf/camel/blob/03a7e99b/spring-boot-dm/camel-starter-parent/pom.xml ---------------------------------------------------------------------- diff --git a/spring-boot-dm/camel-starter-parent/pom.xml b/spring-boot-dm/camel-starter-parent/pom.xml index 03c1c77..6cc94db 100644 --- a/spring-boot-dm/camel-starter-parent/pom.xml +++ b/spring-boot-dm/camel-starter-parent/pom.xml @@ -1,4 +1,20 @@ <?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. +--> <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"> @@ -11,18 +27,18 @@ <artifactId>camel-starter-parent</artifactId> <packaging>pom</packaging> - <name>Camel :: Spring-Boot :: Dependency Management :: Parent</name> + <name>Camel :: Spring-Boot :: Dependency Management :: Starter Parent</name> <description>Camel Spring-Boot Starters Parent POM</description> <dependencies> <!-- Dependencies added for all starters --> <!-- Logback is the default logging implementation in spring-boot but it doesn't provide the log4j2 binding --> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-to-slf4j</artifactId> - <version>${log4j2-version}</version> - </dependency> + <!--<dependency>--> + <!--<groupId>org.apache.logging.log4j</groupId>--> + <!--<artifactId>log4j-to-slf4j</artifactId>--> + <!--<version>${log4j2-version}</version>--> + <!--</dependency>--> </dependencies> <dependencyManagement> @@ -32,7 +48,7 @@ <!-- What's in the user BOM is OK for the parent --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-boot-bom</artifactId> + <artifactId>camel-spring-boot-dependencies</artifactId> <version>${project.version}</version> <type>pom</type> <scope>import</scope> http://git-wip-us.apache.org/repos/asf/camel/blob/03a7e99b/spring-boot-dm/pom.xml ---------------------------------------------------------------------- diff --git a/spring-boot-dm/pom.xml b/spring-boot-dm/pom.xml index 4b51b3d..1514dd9 100644 --- a/spring-boot-dm/pom.xml +++ b/spring-boot-dm/pom.xml @@ -1,4 +1,20 @@ <?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. +--> <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"> @@ -15,10 +31,10 @@ <name>Camel :: Spring-Boot :: Dependency Management</name> <description>Camel Spring-Boot Dependency Management POM</description> <modules> - <module>camel-starter-parent</module> <module>camel-spring-boot-bom</module> <module>camel-spring-boot-generator-bom</module> - <module>camel-spring-boot-bom-ng</module> + <module>camel-spring-boot-dependencies</module> + <module>camel-starter-parent</module> </modules> <properties> http://git-wip-us.apache.org/repos/asf/camel/blob/03a7e99b/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml b/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml index 1e86bc2..74fa755 100644 --- a/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml +++ b/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml @@ -33,7 +33,7 @@ <dependency> <!-- Only the BOM --> <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-boot-bom</artifactId> + <artifactId>camel-spring-boot-dependencies</artifactId> <version>${project.version}</version> <type>pom</type> <scope>import</scope> http://git-wip-us.apache.org/repos/asf/camel/blob/03a7e99b/tests/camel-itest-spring-boot/src/test/resources/dependency-resolver-pom.xml ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/resources/dependency-resolver-pom.xml b/tests/camel-itest-spring-boot/src/test/resources/dependency-resolver-pom.xml index 4e04e0b..f48cf62 100644 --- a/tests/camel-itest-spring-boot/src/test/resources/dependency-resolver-pom.xml +++ b/tests/camel-itest-spring-boot/src/test/resources/dependency-resolver-pom.xml @@ -33,7 +33,7 @@ <dependency> <!-- BOM first --> <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-boot-bom</artifactId> + <artifactId>camel-spring-boot-dependencies</artifactId> <version>${project.version}</version> <type>pom</type> <scope>import</scope> http://git-wip-us.apache.org/repos/asf/camel/blob/03a7e99b/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java b/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java index ab2e14e..b3f8660 100644 --- a/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java +++ b/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java @@ -2,10 +2,12 @@ package org.apache.camel.maven.bom.generator; import java.io.File; import java.io.FileWriter; -import java.util.LinkedList; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; @@ -89,7 +91,7 @@ public class BomGeneratorMojo extends AbstractMojo { } private List<Dependency> filter(List<Dependency> dependencyList) { - List<Dependency> outDependencies = new LinkedList<>(); + List<Dependency> outDependencies = new ArrayList<>(); DependencyMatcher inclusions = new DependencyMatcher(dependencies.getIncludes()); DependencyMatcher exclusions = new DependencyMatcher(dependencies.getExcludes()); @@ -103,6 +105,8 @@ public class BomGeneratorMojo extends AbstractMojo { } } + Collections.sort(outDependencies, (d1, d2) -> (d1.getGroupId() + ":" + d1.getArtifactId()).compareTo(d2.getGroupId() + ":" + d2.getArtifactId())); + return outDependencies; } @@ -113,7 +117,23 @@ public class BomGeneratorMojo extends AbstractMojo { } private void writePom(Document pom) throws Exception { + + XPathFactory xpathFactory = XPathFactory.newInstance(); + // XPath to find empty text nodes. + XPathExpression xpathExp = xpathFactory.newXPath().compile("//text()[normalize-space(.) = '']"); + NodeList emptyTextNodes = (NodeList) xpathExp.evaluate(pom, XPathConstants.NODESET); + + // Remove each empty text node from document. + for (int i = 0; i < emptyTextNodes.getLength(); i++) { + Node emptyTextNode = emptyTextNodes.item(i); + emptyTextNode.getParentNode().removeChild(emptyTextNode); + } + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + DOMSource source = new DOMSource(pom); targetPom.getParentFile().mkdirs(); @@ -174,11 +194,11 @@ public class BomGeneratorMojo extends AbstractMojo { dependencyEl.appendChild(scopeEl); } - if(dep.getExclusions()!=null) { + if (dep.getExclusions() != null && !dep.getExclusions().isEmpty()) { Element exclsEl = pom.createElement("exclusions"); - for(Exclusion e : dep.getExclusions()) { + for (Exclusion e : dep.getExclusions()) { Element exclEl = pom.createElement("exclusion"); Element groupIdExEl = pom.createElement("groupId");