Mojo

Submission of properties-maven-plugin

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: _Plugin Submission
  • Labels:
    None
  • Environment:
    Platform independent
  • Complexity:
    Intermediate
  • Number of attachments :
    3

Description

As posted on the Mojo-Dev and Maven-User mailing lists, I've created a properties-maven-plugin which provides I/O functionality for maven properties, a feature often requested on the mailing lists.

The site for the plugin:
http://individual.utoronto.ca/zarar/properties-maven-plugin/site/

My mailing list posts about the plugin:
http://www.nabble.com/properties-maven-plugin-tf2455107.html
http://www.nabble.com/Any-interest-in-a-maven-properties-plugin--tf2454363.html

The source for the plugin is attached. Is it possible for this to be placed in the sandbox so further development may be done on it?

Thanks.

Activity

Hide
Trygve Laugstol added a comment -

I would still like to understand what this plugin is supposed to do. Sounds to me like it might be something that might fit in the resources or build helper plugins.

Show
Trygve Laugstol added a comment - I would still like to understand what this plugin is supposed to do. Sounds to me like it might be something that might fit in the resources or build helper plugins.
Hide
Zarar Siddiqi added a comment -

Yes, this could be part of the build helper plugin since this is a very common task in the build process.

There are two main use cases for this plugin (maybe more for others):

1. Ability to define Maven properties in a property file

So instead of this:

<properties>
   <webmaster.name>The Dude</webmaster.name>
   <webmaster.email>dude@dude.com</webmaster.email>
</properties>

we can define them in a property file

webmaster.name=The Dude
webmaster.email=dude@dude.com

This will allow developers to easily load different properties based on different environments. Many applications have varying configuration properties for different environments and this would help maintain them in seperate files rather than having everything in a pom and using profiles which many find overkill for such circumstances.

2. Writing ALL Maven properties to a file

Maven properties which were created in pom.xml or loaded via #1 could be written to a file. This comes handy when these properties need to be available at runtime. The best example I can think of is the property files needed to initialize Spring's PropertyPlaceholderConfigurer.

Show
Zarar Siddiqi added a comment - Yes, this could be part of the build helper plugin since this is a very common task in the build process. There are two main use cases for this plugin (maybe more for others):

1. Ability to define Maven properties in a property file

So instead of this:
<properties>
   <webmaster.name>The Dude</webmaster.name>
   <webmaster.email>dude@dude.com</webmaster.email>
</properties>
we can define them in a property file
webmaster.name=The Dude
webmaster.email=dude@dude.com
This will allow developers to easily load different properties based on different environments. Many applications have varying configuration properties for different environments and this would help maintain them in seperate files rather than having everything in a pom and using profiles which many find overkill for such circumstances.

2. Writing ALL Maven properties to a file

Maven properties which were created in pom.xml or loaded via #1 could be written to a file. This comes handy when these properties need to be available at runtime. The best example I can think of is the property files needed to initialize Spring's PropertyPlaceholderConfigurer.
Hide
Zarar Siddiqi added a comment -

Any decision on this plugin? It will be useful to many people here.

If it's made part of the build-helper plugin, that would work fine too.

Show
Zarar Siddiqi added a comment - Any decision on this plugin? It will be useful to many people here. If it's made part of the build-helper plugin, that would work fine too.
Hide
Corporate Gadfly added a comment -

Modification for reading properties which includes expansion of ${} tokens against project properties, system properties and environment variables. E.g., if a .properties file contains:

war.dir=${env.HOME}/${env.OS}

and the environment variables HOME and OS have values ABC and Windows_NT

when the property is available to maven, this will be expanded to:

war.dir=ABC/Windows_NT
Show
Corporate Gadfly added a comment - Modification for reading properties which includes expansion of ${} tokens against project properties, system properties and environment variables. E.g., if a .properties file contains:
war.dir=${env.HOME}/${env.OS}
and the environment variables HOME and OS have values ABC and Windows_NT when the property is available to maven, this will be expanded to:
war.dir=ABC/Windows_NT
Hide
tom nelson added a comment -

This is a fabulous idea and a huge help when you are faced with using the
antrun plugin on an ant file that depends on a big properties file.

Tom Nelson

Show
tom nelson added a comment - This is a fabulous idea and a huge help when you are faced with using the antrun plugin on an ant file that depends on a big properties file. Tom Nelson
Hide
Matt Raible added a comment -

Any chance this plugin could be enhanced to allow overriding of properties in dependent poms?

http://jira.codehaus.org/browse/MNG-2757

Show
Matt Raible added a comment - Any chance this plugin could be enhanced to allow overriding of properties in dependent poms? http://jira.codehaus.org/browse/MNG-2757
Hide
Zarar Siddiqi added a comment -

An updated version of this plugin can be downloaded from here:

http://arsenalist.com/2007/02/07/maven-properties-plugin-download/

It has the additional feature of the properties being defined being able to use other properties.

This plugin gets downloaded a bunch of times everyday and I really don't see why this hasn't been accepted yet.

Show
Zarar Siddiqi added a comment - An updated version of this plugin can be downloaded from here: http://arsenalist.com/2007/02/07/maven-properties-plugin-download/ It has the additional feature of the properties being defined being able to use other properties. This plugin gets downloaded a bunch of times everyday and I really don't see why this hasn't been accepted yet.
Hide
Carlos Sanchez added a comment -

I apologize, given the amount of votes if you want we can give you access to the sandbox
Sign up at http://xircles.codehaus.org/signup
Request being a project member at http://xircles.codehaus.org/projects/mojo

Show
Carlos Sanchez added a comment - I apologize, given the amount of votes if you want we can give you access to the sandbox Sign up at http://xircles.codehaus.org/signup Request being a project member at http://xircles.codehaus.org/projects/mojo
Hide
Carlos Sanchez added a comment -

added Zarar to the project

Show
Carlos Sanchez added a comment - added Zarar to the project
Hide
Zarar Siddiqi added a comment -

This is now in SVN:

https://svn.codehaus.org/mojo/trunk/mojo/properties-maven-plugin/

Thanks to everyone for voting. Thanks again Carlos.

Show
Zarar Siddiqi added a comment - This is now in SVN: https://svn.codehaus.org/mojo/trunk/mojo/properties-maven-plugin/ Thanks to everyone for voting. Thanks again Carlos.
Hide
Carlos Sanchez added a comment -
Show
Carlos Sanchez added a comment - moved to the sandbox until released https://svn.codehaus.org/mojo/trunk/mojo/mojo-sandbox/properties-maven-plugin/
Hide
Daniel Harvey added a comment -

FYI, the sandbox URL has moved to https://svn.codehaus.org/mojo/trunk/sandbox/properties-maven-plugin/

BTW, I'm still keen to see this plugin released.

Show
Daniel Harvey added a comment - FYI, the sandbox URL has moved to https://svn.codehaus.org/mojo/trunk/sandbox/properties-maven-plugin/ BTW, I'm still keen to see this plugin released.
Hide
Tony Dalbrekt added a comment -

To write all project properties to file is not always desirable. The attached patch adds class (goal) WriteProperties which writes properties of your choice to outputFile. It would be nice if you committed this patch and I would also like to see this plugin be released in some way.

Usage:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <executions>
        <execution> 
            <phase>generate-resources</phase>
            <goals>
                <goal>write-properties</goal>
            </goals>
            <configuration>
                <addBuildDate>true</addBuildDate>
                <properties>
                    <property>
                        <name>project.version</name>
                        <value>${project.version}</value>
                    </property>
                    <property>
                        <name>project.name</name>
                        <value>${project.name}</value>
                    </property>
                </properties>
                <outputFile>
                    target/classes/app.properties
                </outputFile>
            </configuration>
        </execution>
    </execusions>
</plugin>
Show
Tony Dalbrekt added a comment - To write all project properties to file is not always desirable. The attached patch adds class (goal) WriteProperties which writes properties of your choice to outputFile. It would be nice if you committed this patch and I would also like to see this plugin be released in some way. Usage:
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <executions>
        <execution> 
            <phase>generate-resources</phase>
            <goals>
                <goal>write-properties</goal>
            </goals>
            <configuration>
                <addBuildDate>true</addBuildDate>
                <properties>
                    <property>
                        <name>project.version</name>
                        <value>${project.version}</value>
                    </property>
                    <property>
                        <name>project.name</name>
                        <value>${project.name}</value>
                    </property>
                </properties>
                <outputFile>
                    target/classes/app.properties
                </outputFile>
            </configuration>
        </execution>
    </execusions>
</plugin>

People

Vote (16)
Watch (17)

Dates

  • Created:
    Updated:
    Resolved: