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 d9be3a4118fa74ea01a011e6005160b8bf0fb62b Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu May 7 09:59:36 2020 +0200 Add license header to generated camel-dependencies pom --- etc/apache-header.xml | 18 ++++++++++++++++++ .../maven/sync/properties/SyncPropertiesMojo.java | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/etc/apache-header.xml b/etc/apache-header.xml new file mode 100644 index 0000000..913a5ff --- /dev/null +++ b/etc/apache-header.xml @@ -0,0 +1,18 @@ +<!-- + + 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. + +--> \ No newline at end of file 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 54f8e4b..d199a03 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 @@ -17,11 +17,14 @@ package org.apache.camel.maven.sync.properties; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; +import java.nio.file.Files; import java.util.Properties; import java.util.TreeMap; +import org.apache.camel.util.IOHelper; import org.apache.camel.util.OrderedProperties; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; @@ -52,6 +55,12 @@ public class SyncPropertiesMojo extends AbstractMojo { @Parameter(defaultValue = "${basedir}/../../../camel-dependencies/pom.xml") protected File targetPom; + /** + * The license header file. + */ + @Parameter(defaultValue = "${basedir}/../../etc/apache-header.xml") + protected File licenceHeader; + @Override public void execute() throws MojoExecutionException, MojoFailureException { try { @@ -77,6 +86,16 @@ public class SyncPropertiesMojo extends AbstractMojo { MavenXpp3Writer mavenWriter = new MavenXpp3Writer(); mavenWriter.write(new FileWriter(targetPom), model); } + + // add license header in top + String text = IOHelper.loadText(new FileInputStream(targetPom)); + String text2 = IOHelper.loadText(new FileInputStream(licenceHeader)); + StringBuffer sb = new StringBuffer(text); + int pos = sb.indexOf("<project"); + sb.insert(pos, text2); + + // write lines + Files.writeString(targetPom.toPath(), sb.toString()); } catch (Exception ex) { throw new MojoExecutionException("Cannot copy the properties between POMs", ex); }