diff --git a/.gitignore b/.gitignore index 252d3b1..3a486d9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ target .settings .project .classpath +.idea/ +*.iml \ No newline at end of file diff --git a/acceptance/acceptance-test/pom.xml b/acceptance/acceptance-test/pom.xml index 3cdf68f..e33a53e 100644 --- a/acceptance/acceptance-test/pom.xml +++ b/acceptance/acceptance-test/pom.xml @@ -73,6 +73,29 @@ read-project-properties + + generate-sources + + write-custom-properties + + + ${project.build.outputDirectory}/META-INF/build.properties + + + Application-Name + ${project.build.finalName} + + + Application.version + ${project.version} + + + Application-Build-Timestamp + ${maven.build.timestamp} + + + + diff --git a/pom.xml b/pom.xml index 85910ff..ea4c0be 100644 --- a/pom.xml +++ b/pom.xml @@ -96,6 +96,11 @@ Tim Gordon timothygordon32@gmail.com + + okohub + Onur Kağan Özcan + onurkaganozcan@gmail.com + diff --git a/src/main/java/org/codehaus/mojo/properties/WriteCustomProperties.java b/src/main/java/org/codehaus/mojo/properties/WriteCustomProperties.java new file mode 100644 index 0000000..6bd3e65 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/properties/WriteCustomProperties.java @@ -0,0 +1,53 @@ +package org.codehaus.mojo.properties; + +/* + * 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. + */ + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +import java.util.Properties; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +/** + * Writes custom properties to a file. + * + * @author Onur Kağan Özcan + * @version $Id$ + */ +@Mojo( name = "write-custom-properties", defaultPhase = LifecyclePhase.NONE, threadSafe = true ) +public class WriteCustomProperties + extends AbstractWritePropertiesMojo +{ + + /** + * The custom properties to set. + */ + @Parameter(name = "properties", required = true) + private Properties properties; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + validateOutputFile(); + writeProperties(properties, getOutputFile()); + } +} diff --git a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml index ca3fbb1..1e92218 100644 --- a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml +++ b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml @@ -27,5 +27,18 @@ + + + + write-custom-properties + + + + + true + true + + + diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt index a781ab0..234e638 100644 --- a/src/site/apt/index.apt +++ b/src/site/apt/index.apt @@ -54,6 +54,8 @@ Properties Maven Plugin * {{{./set-system-properties-mojo.html}properties:set-system-properties}} Sets system properties. + * {{{./write-custom-properties-mojo.html}properties:write-custom-properties}} Writes custom properties. + * Usage diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 79d9bb0..a529599 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -168,3 +168,39 @@ Usage ---------------- + + * write-custom-properties + + The {{{./write-custom-properties-mojo.html}properties:write-custom-properties}} + goal writes custom properties to a file. + + ---------------- + + + + + org.codehaus.mojo + properties-maven-plugin + ${project.version} + + + generate-sources + + write-custom-properties + + + \${project.build.outputDirectory}/META-INF/build.properties + + + my.property.name + my.property.value + + + + + + + + + + ---------------- \ No newline at end of file