This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit c9f23db1b95f989d5f11b2d19d7a685ca0c35e0e Author: Claus Ibsen <[email protected]> AuthorDate: Wed May 6 09:48:13 2020 +0200 CAMEL-14812: Lets sort the generated dependencies --- tooling/maven/sync-properties-maven-plugin/pom.xml | 197 ++++++++++++--------- .../maven/sync/properties/SyncPropertiesMojo.java | 13 +- 2 files changed, 120 insertions(+), 90 deletions(-) diff --git a/tooling/maven/sync-properties-maven-plugin/pom.xml b/tooling/maven/sync-properties-maven-plugin/pom.xml index 11df8d4..11a2b55 100644 --- a/tooling/maven/sync-properties-maven-plugin/pom.xml +++ b/tooling/maven/sync-properties-maven-plugin/pom.xml @@ -1,88 +1,117 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>maven-plugins</artifactId> - <version>3.3.0-SNAPSHOT</version> - </parent> - <artifactId>sync-properties-maven-plugin</artifactId> - <packaging>maven-plugin</packaging> - <name>Camel :: Maven Plugins :: Sync Properties</name> - <description>Maven plugin to help generating Sync Properties between POMs</description> - <dependencyManagement> - <dependencies> - <dependency> +<!-- + + 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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <parent> <groupId>org.apache.camel</groupId> - <artifactId>tooling-parent</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> + <artifactId>maven-plugins</artifactId> + <version>3.3.0-SNAPSHOT</version> + </parent> + + <artifactId>sync-properties-maven-plugin</artifactId> + <packaging>maven-plugin</packaging> + <name>Camel :: Maven Plugins :: Sync Properties</name> + <description>Maven plugin to help generating Sync Properties between POMs</description> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>tooling-parent</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-util</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven.resolver</groupId> + <artifactId>maven-resolver-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven.resolver</groupId> + <artifactId>maven-resolver-util</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-compat</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-container-default</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </dependency> + <dependency> + <groupId>org.sonatype.plexus</groupId> + <artifactId>plexus-build-api</artifactId> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>test</scope> + </dependency> </dependencies> - </dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.maven.resolver</groupId> - <artifactId>maven-resolver-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven.resolver</groupId> - <artifactId>maven-resolver-util</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-artifact</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-plugin-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven.plugin-tools</groupId> - <artifactId>maven-plugin-annotations</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-compat</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> - </dependency> - <dependency> - <groupId>org.sonatype.plexus</groupId> - <artifactId>plexus-build-api</artifactId> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-plugin-plugin</artifactId> - <configuration> - <mojoDependencies> - <dep>org.apache.maven:maven-plugin-api</dep> - </mojoDependencies> - </configuration> - </plugin> - </plugins> - </build> + + <build> + <plugins> + <plugin> + <artifactId>maven-plugin-plugin</artifactId> + <configuration> + <mojoDependencies> + <dep>org.apache.maven:maven-plugin-api</dep> + </mojoDependencies> + </configuration> + </plugin> + </plugins> + </build> + </project> diff --git a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java index d5908f5..54f8e4b 100644 --- a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java +++ b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java @@ -20,8 +20,9 @@ import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.util.Properties; -import java.util.Set; +import java.util.TreeMap; +import org.apache.camel.util.OrderedProperties; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; @@ -66,12 +67,12 @@ public class SyncPropertiesMojo extends AbstractMojo { MavenXpp3Reader mavenReader = new MavenXpp3Reader(); Model model = mavenReader.read(reader); + // lets sort the properties + OrderedProperties op = new OrderedProperties(); + op.putAll(new TreeMap<>(parentProp)); + MavenProject project = new MavenProject(model); - project.getProperties().clear(); - Set<String> keys = parentProp.stringPropertyNames(); - for (String key : keys) { - project.getProperties().setProperty(key, parentProp.getProperty(key)); - } + project.getModel().setProperties(op); MavenXpp3Writer mavenWriter = new MavenXpp3Writer(); mavenWriter.write(new FileWriter(targetPom), model);
