NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

How should I set Maven build properties?

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Ken Tanaka
Posted via mailing list.





PostPosted: Wed Jul 07, 2010 9:59 pm    Post subject: How should I set Maven build properties? Reply with quote

I'm using NetBeans 6.8 with Maven 2.2.1 and would like to pass a blank
password to fill in some values in a configuration file. Most of the
specifics can be dealt with by profiles and a filter file, but I don't
want the passwords to go into version control, so those can be fed in on
the command line with

mvn install -Dpass1=foo -Dpass2= -Dpass3=bar

If I want to build inside of NetBeans, I've tried opening the project
properties,
in the Categories I chose "Configurations" and added a "newconfig" with
profile "xprofile"
then in the Categories I chose "Actions" and selected "Configuration:
newconfig (Profiles: [xprofile])"
then next to "Actions:" selecting "Build project",
and next to "Set Properties:" adding (one per line)
pass1=foo
pass2=
pass3=bar

Any entries missing a value like pass2 will be dropped from the list,
and NetBeans will execute

mvn -Dpass3=bar -Dpass1=foo -Dnetbeans.execution=true --fail-fast
-Pxprofile install

Am I not going about this the right way? I've also tried to Set
Properties as
pass2="" or
pass2='' or
pass2="''"
but these all get culled from the list for having blank values. We are
using Hudson for continuous integration, so I can configure the
passwords as additional parameters in the build. I just can't figure out
how to set up NetBeans to do the same thing. Does anyone have a solution?

-Ken
Back to top
Ken Tanaka
Posted via mailing list.





PostPosted: Fri Jul 09, 2010 8:20 pm    Post subject: How should I set Maven build properties? Reply with quote

After doing some more experiments, I think I have a work around for
anyone who has a similar need to define names that may need blank values
in a Maven project, mixed with non-blank values that shouldn't be in
version control, and still buildable with NetBeans filling in the
properties.

I recommend setting blank values for all the parameters that will be
needed on the command line to build in the pom.xml like this:

<profiles>
<profile>
<id>xprofile</id>
<activation>
<property>
<name>!targetEnv</name>
</property>
</activation>
<properties>
<targetEnv>development</targetEnv>
<pass1></pass1>
<pass2></pass2>
<pass3></pass3>
<log.path>target</log.path>
</properties>
</profile>
</profiles>

Then if any of the values should be blank, they are defined and ready to
use, even if NetBeans can't pass an empty value. The values defined on
the command line with "-D" will override the pom.xml settings.

Note: For those seeing red flags, for development there is an empty
password, but it's a read-only internal connection to a test database.
For production all passwords will be non-empty. But this technique can
apply to anything that you need to configure at build time, such as
optional prefixes, where an empty string may be a valid value.

-Ken

Ken Tanaka wrote:
Quote:
I'm using NetBeans 6.8 with Maven 2.2.1 and would like to pass a blank
password to fill in some values in a configuration file. Most of the
specifics can be dealt with by profiles and a filter file, but I don't
want the passwords to go into version control, so those can be fed in
on the command line with

mvn install -Dpass1=foo -Dpass2= -Dpass3=bar

If I want to build inside of NetBeans, I've tried opening the project
properties,
in the Categories I chose "Configurations" and added a "newconfig"
with profile "xprofile"
then in the Categories I chose "Actions" and selected "Configuration:
newconfig (Profiles: [xprofile])"
then next to "Actions:" selecting "Build project",
and next to "Set Properties:" adding (one per line)
pass1=foo
pass2=
pass3=bar

Any entries missing a value like pass2 will be dropped from the list,
and NetBeans will execute

mvn -Dpass3=bar -Dpass1=foo -Dnetbeans.execution=true --fail-fast
-Pxprofile install

Am I not going about this the right way? I've also tried to Set
Properties as
pass2="" or
pass2='' or
pass2="''"
but these all get culled from the list for having blank values. We are
using Hudson for continuous integration, so I can configure the
passwords as additional parameters in the build. I just can't figure
out how to set up NetBeans to do the same thing. Does anyone have a
solution?

-Ken
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo