Re: Maven - Property files Question

2009-07-07 Thread mavenusr

Dave,
Thanks a lot for your inputs.

Regards
Sundar

mavenusr wrote:
> 
> Hello,
> 
> I m new to Maven and I m trying to place property and config.xml files
> outside the Jar files. Here is my current directory
> 
> Src
>  main
>   java
>   resources
> test
>  java
>   resources
> 
> under java, i have all the java class files and in resources folder i have
> the properties and springbatch xml files.
> 
> when i package the application, the property files which are under
> src/main/resources is also getting included. I need to place this outside
> the jar file so that the application can pickup when ever i make any
> changes
> to the property. currently i need to package again whenever a small change
> is made.
> 
> please help.
> 
> Thanks,
> Sundar
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Maven---Property-files-Question-tp24214839p24376326.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Maven - Property files Question

2009-07-07 Thread David Weintraub
On Mon, Jul 6, 2009 at 5:03 PM, mavenusr wrote:
>
> Thanks. Yes. My property files aren't part of the JAR.
>
> so again my question is, if i change the property files, will the JAR
> automically pickup the change without the need for rebuilding it?

No. If none of the files that make up your jar file are changed, the
jar file simply isn't rebuilt. Maven is really extremely good at this.
Much better than Ant.

However, if you build an assembly (that is you package that jar file
with your properties files in a tarball or a zipfile), the assembly
will be rebuilt! I mention this because I explained how to build an
assembly back in my reply to you on June 26.

That makes perfect sense. Jar file isn't rebuilt because none of the
files in it are changed. Assembly flie is rebuilt because the
properties file in it was changed.

Now, by default, Maven doesn't build assemblies on the package
lifecycle -- only the jar flie. So, by default, if you do:

$ mvn package

And, you changed your properties file, but nothing else, the "mvn
package" won't do anything except print out a lot of garbage.

If you changed your properties file, but not any of the files that
make up the jar, and you do this:

   $ mvn assembly:assembly

The assembly will be rebuilt. The jar file won't be, but a new
assembly tarball or zip file will be rebuilt.

The only reason I'm mentioning this is that you can change Maven's
default behavior by telling Maven to build the assembly on the package
lifecycle step. Again, I mentioned how to do this in my June 26 reply
to you.

Therefore, if you changed your pom.xml file to build your assembly on
the package stage of your development lifecycle, doing this:

   $ mvn package

Will do something: It won't rebuild your jar file, but it will rebuild
your assembly.

-- 
David Weintraub
qazw...@gmail.com

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Maven - Property files Question

2009-07-06 Thread mavenusr

Thanks. Yes. My property files are n't part of the JAR.

so again my question is, if i change the property files, will the JAR
automically pickup the change without the need for rebuilding it?


David Weintraub wrote:
> 
> On Mon, Jul 6, 2009 at 3:29 PM, mavenusr wrote:
>> one last question. If i want to update the property files, will my jar
>> file
>> picksup the updates automatically or do i need to build it again?
> 
> Um... I thought the properties file wasn't in your JAR.
> 
> If you put the properties file in another directory besides the
> resources directory, or if you exclude the properties files from the
> jar, but the properties files are still in the /src/main/resources
> directory, then your JAR will not rebuild if someone changes the
> properties files.
> 
> HOWEVER, if the properties files are included in your jarfile. Yes,
> your jarfile will rebuild.
> 
> Basically, whether your jar file rebuilds or not depends if any of the
> files inside the jar are changed. I've found Maven pretty good at
> keeping track of those types of things.
> 
> -- 
> David Weintraub
> qazw...@gmail.com
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Maven---Property-files-Question-tp24214839p24362768.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Maven - Property files Question

2009-07-06 Thread David Weintraub
On Mon, Jul 6, 2009 at 3:29 PM, mavenusr wrote:
> one last question. If i want to update the property files, will my jar file
> picksup the updates automatically or do i need to build it again?

Um... I thought the properties file wasn't in your JAR.

If you put the properties file in another directory besides the
resources directory, or if you exclude the properties files from the
jar, but the properties files are still in the /src/main/resources
directory, then your JAR will not rebuild if someone changes the
properties files.

HOWEVER, if the properties files are included in your jarfile. Yes,
your jarfile will rebuild.

Basically, whether your jar file rebuilds or not depends if any of the
files inside the jar are changed. I've found Maven pretty good at
keeping track of those types of things.

-- 
David Weintraub
qazw...@gmail.com

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Maven - Property files Question

2009-07-06 Thread mavenusr
gt; Thanks for your reply. I m not trying to place resources folder outside
>> the
>> jar. I m trying to place the properties file that reside in resources
>> folder
>> outside the jar so that my application can pickup. What should i modify
>> in
>> my pom.xml?
>>
>> Thanks,
>> Sundar
>>
>>
>> On 6/25/09, sundar varadarajan  wrote:
>>>
>>> Hello,
>>>
>>> I m new to Maven and I m trying to place property and config.xml files
>>> outside the Jar files. Here is my current directory
>>>
>>> Src
>>>  main
>>>   java
>>>   resources
>>> test
>>>  java
>>>   resources
>>>
>>> under java, i have all the java class files and in resources folder i
>>> have
>>> the properties and springbatch xml files.
>>>
>>> when i package the application, the property files which are under
>>> src/main/resources is also getting included. I need to place this
>>> outside
>>> the jar file so that the application can pickup when ever i make any
>>> changes
>>> to the property. currently i need to package again whenever a small
>>> change
>>> is made.
>>>
>>> please help.
>>>
>>> Thanks,
>>> Sundar
>>>
>>
> 
> 
> 
> -- 
> David Weintraub
> qazw...@gmail.com
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Maven---Property-files-Question-tp24214839p24361473.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Maven - Property files Question

2009-06-29 Thread David Weintraub
There are two issues I addressed in my previous email:

Issue #1: How do you prevent those properties files from being
packaged inside your jarfile, and Issue #2: How to make those
properties files available as a release product.

Let's start with Issue #1: Preventing your jar file from containing
those properties files. I gave you two recommendations:

Recommendation #1) Remove those properties files from your resources
directory, and put them in another directory under src/main. I
recommended calling it src/main/properties, but someone else wrote in
and said the standard is src/main/filters (although it really isn't a
resource filter).

This way, the standard Maven behavior will not copy those properties
files into your jar because those properties files are not in your
resources directory. It's simple and easy to implement.

Recommendation #2).Although the preferred way of preventing the
properties files from being included inside your jar is to put them
into another directory, there might be reasons beyond your control why
this isn't possible. Maybe that's the way management has decreed, and
you can't get them to change their mind. Maybe your developers have
already setup their Eclipse projects and will complain bitterly if you
try to change them.

Fortunately, there is a way in Maven to handle this. You can use
filtering to skip over your properties files when Maven is copying in
all the other files in your resources directory into your jar. Notice
that this still does copy almost all of the files in your resources
folder into your jar. All it merely does is define what you want
copied or don't want copied to your jar file.

I gave you a link that explains exactly how to do this:
.

Now, let's talk about Issue #2: Distributing those properties files.

Normally in Maven, you are packaging a jar file or a warfile or an ear
file for distribution, and this is placed into your Maven repository
when you deploy it. However, there are times you also need to
distribute other files with your jar or war. For example, javadocs,
source files, or even properties files.

To do this, you use the assemblies plugin. This involves defining an
assembly file which basically tells Maven how to package your files.
This is completely up to you. You could create a zipfile or a tarball
or a compressed tarball containing your properties files along with
your jar file, or maybe you just want the properties files zipped up
(or tarred up) as their own package.

You explain to Maven in an assembly file stored in src/main/assembly
how to do the packaging. I gave you an example I used in my previous
email. You have almost free reign in defining this packaging to suit
your own needs.

Once you create an assembly file, you need to modify your pom to know
about the assembly file (or files: You can have more than one). Again,
I gave you an example from my own pom.xml. This goes into the
 section of your pom.xml:


org.apache.maven.plugins
 maven-assembly-plugin
 2.2-beta-3
 
 
 src/main/assemblies/bin.xml
  
 



Now, when you do:

$ mvn assembly:assembly

Maven will build your "assembly" which is the package that contains
the properties files.

Of course, if you don' want to do this separate step, but want the
assembly to be built when someone does:

$ mvn package

you need to add a few more lines into the pom.xml to tell Maven to
build the assemblies in the "package" phase of the life cycle. To do
this, replace the commend line above:

 

with this:



  package
  
   single
  
 


This will execute the assembly:single stage in the lifecycle "package" phase.

Now, when you do:

$ mvn package

Both the jar file (without the properties) and a zip or tar package
containing the properties will be placed in the target directory.

On Fri, Jun 26, 2009 at 12:52 PM, sundar
varadarajan wrote:
> Hi Dave,
>
> Thanks for your reply. I m not trying to place resources folder outside the
> jar. I m trying to place the properties file that reside in resources folder
> outside the jar so that my application can pickup. What should i modify in
> my pom.xml?
>
> Thanks,
> Sundar
>
>
> On 6/25/09, sundar varadarajan  wrote:
>>
>> Hello,
>>
>> I m new to Maven and I m trying to place property and config.xml files
>> outside the Jar files. Here is my current directory
>>
>> Src
>>  main
>>   java
>>   resources
>> test
>>  java
>>   resources
>>
>> under java, i have all the java class files and in resources folder i have
>> the properties and springbatch xml files.
>>
>> when i package the application, the property files which are under
>> src/main/resources is also getting included. I need to place this outside
>> the jar file so that the application can pickup when ever i make any changes
>> to the property. currently i need to package again whenever a sma

Re: Maven - Property files Question

2009-06-26 Thread John Prystash
How about src/main/filters?

http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html





From: David Weintraub 
To: Maven Users List 
Sent: Friday, June 26, 2009 1:33:52 PM
Subject: Re: Maven - Property files Question

By default, the resources:resources lifecycle automatically copies
everything in the resources folder over to the target/classes folder
when it builds the war or jar.

In order to avoid this, you need to move your property files to
another folder, or if that's not possible, configure the
resources:resources step to skip these files. I recommend that you
create another folder like src/main/properties and stick your property
files in there.

See 
<http://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html>
for information on skipping packaging certain files in your jar/war.

You will also need the assembly plugin to package your war with your
properties files as maybe a zip or tarball. See
<http://maven.apache.org/plugins/maven-assembly-plugin/> for
information about the assembly plugin.

Assemblies took me a while to understand. Basically, you create (by
convention) a folder called src/main/assemblies, and you define your
assembly XML files in there. You could have multiple ways of
packaging. For example, you might have one that includes only the
files you install while another includes some documents or source
files.

Normally, you call the assembly XML bin.xml, and the final package
will be something like foo-1.3-bin.zip. That is, this is version 1.3
of artifact "foo", and this is a zip file built by the "bin" assembly.
You could have things like foo-1.3-src.zip, etc.

Then, in your pom.xml, you have to define where the assembly files are
located, and you might also want to modify the lifecycle, so that your
assemblies are built when you do the mvn package. Otherwise, you'll
have to run mvn assembly:assembly.

To give you a better idea, this is what I have in my project's pom.xml
file under the  section:


org.apache.maven.plugins
maven-assembly-plugin
2.2-beta-3



src/main/assemblies/bin.xml




package

single






The  defines where my assembly file lives, and I could
have multiple descriptors.

The  defines that my assembly should be built in the
package phase, so I don't have to remember to run "mvn
assembly:assembly" in order to build the assembly.

The assembly itself is pretty simple:

assembly>
bin

tar.gz

${artifactId}-${version}
false


lib
false
runtime




src/main/bin
bin
lf
0755

**



src/main/config

client/${client}/config
lf
0644

**





Hope this helps.

On Thu, Jun 25, 2009 at 4:19 PM, sundar
varadarajan wrote:
> Hello,
>
> I m new to Maven and I m trying to place property and config.xml files
> outside the Jar files. Here is my current directory
>
> Src
>  main
>  java
>  resources
> test
>  java
>  resources
>
> under java, i have all the java class files and in resources folder i have
> the properties and springbatch xml files.
>
> when i package the application, the property files which are under
> src/main/resources is also getting included. I need to place this outside
> the jar file so that the application can pickup when ever i make any changes
> to the property. currently i need to package again whenever a small change
> is made.
>
> please help.
>
> Thanks,
> Sundar
>



-- 
David Weintraub
qazw...@gmail.com

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org


  

Re: Maven - Property files Question

2009-06-26 Thread sundar varadarajan
Hi Dave,

Thanks for your reply. I m not trying to place resources folder outside the
jar. I m trying to place the properties file that reside in resources folder
outside the jar so that my application can pickup. What should i modify in
my pom.xml?

Thanks,
Sundar


On 6/25/09, sundar varadarajan  wrote:
>
> Hello,
>
> I m new to Maven and I m trying to place property and config.xml files
> outside the Jar files. Here is my current directory
>
> Src
>  main
>   java
>   resources
> test
>  java
>   resources
>
> under java, i have all the java class files and in resources folder i have
> the properties and springbatch xml files.
>
> when i package the application, the property files which are under
> src/main/resources is also getting included. I need to place this outside
> the jar file so that the application can pickup when ever i make any changes
> to the property. currently i need to package again whenever a small change
> is made.
>
> please help.
>
> Thanks,
> Sundar
>


Re: Maven - Property files Question

2009-06-26 Thread David Weintraub
By default, the resources:resources lifecycle automatically copies
everything in the resources folder over to the target/classes folder
when it builds the war or jar.

In order to avoid this, you need to move your property files to
another folder, or if that's not possible, configure the
resources:resources step to skip these files. I recommend that you
create another folder like src/main/properties and stick your property
files in there.

See 

for information on skipping packaging certain files in your jar/war.

You will also need the assembly plugin to package your war with your
properties files as maybe a zip or tarball. See
 for
information about the assembly plugin.

Assemblies took me a while to understand. Basically, you create (by
convention) a folder called src/main/assemblies, and you define your
assembly XML files in there. You could have multiple ways of
packaging. For example, you might have one that includes only the
files you install while another includes some documents or source
files.

Normally, you call the assembly XML bin.xml, and the final package
will be something like foo-1.3-bin.zip. That is, this is version 1.3
of artifact "foo", and this is a zip file built by the "bin" assembly.
You could have things like foo-1.3-src.zip, etc.

Then, in your pom.xml, you have to define where the assembly files are
located, and you might also want to modify the lifecycle, so that your
assemblies are built when you do the mvn package. Otherwise, you'll
have to run mvn assembly:assembly.

To give you a better idea, this is what I have in my project's pom.xml
file under the  section:


org.apache.maven.plugins
maven-assembly-plugin
2.2-beta-3



src/main/assemblies/bin.xml




package

single






The  defines where my assembly file lives, and I could
have multiple descriptors.

The  defines that my assembly should be built in the
package phase, so I don't have to remember to run "mvn
assembly:assembly" in order to build the assembly.

The assembly itself is pretty simple:

assembly>
bin

tar.gz

${artifactId}-${version}
false


lib
false
runtime




src/main/bin
bin
lf
0755

**



src/main/config

client/${client}/config
lf
0644

**





Hope this helps.

On Thu, Jun 25, 2009 at 4:19 PM, sundar
varadarajan wrote:
> Hello,
>
> I m new to Maven and I m trying to place property and config.xml files
> outside the Jar files. Here is my current directory
>
> Src
>  main
>  java
>  resources
> test
>  java
>  resources
>
> under java, i have all the java class files and in resources folder i have
> the properties and springbatch xml files.
>
> when i package the application, the property files which are under
> src/main/resources is also getting included. I need to place this outside
> the jar file so that the application can pickup when ever i make any changes
> to the property. currently i need to package again whenever a small change
> is made.
>
> please help.
>
> Thanks,
> Sundar
>



-- 
David Weintraub
qazw...@gmail.com

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Maven - Property files Question

2009-06-26 Thread sundarvarad


David Hoffer wrote:
> 
> The resources is a standard maven folder and will be included in the
> build/jar/war/etc.  Unfortunately there is no standard for the external
> stuff, you can put those in a different folder and then use the assembly
> or
> similar plugin to deal with them.
> 
> -Dave
> 
> On Thu, Jun 25, 2009 at 2:19 PM, sundar varadarajan
> wrote:
> 
>> Hello,
>>
>> I m new to Maven and I m trying to place property and config.xml files
>> outside the Jar files. Here is my current directory
>>
>> Src
>>  main
>>  java
>>  resources
>> test
>>  java
>>  resources
>>
>> under java, i have all the java class files and in resources folder i
>> have
>> the properties and springbatch xml files.
>>
>> when i package the application, the property files which are under
>> src/main/resources is also getting included. I need to place this outside
>> the jar file so that the application can pickup when ever i make any
>> changes
>> to the property. currently i need to package again whenever a small
>> change
>> is made.
>>
>> please help.
>>
>> Thanks,
>> Sundar
>>
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/Maven---Property-files-Question-tp3159654p3162714.html
Sent from the maven users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Maven - Property files Question

2009-06-25 Thread David Hoffer
The resources is a standard maven folder and will be included in the
build/jar/war/etc.  Unfortunately there is no standard for the external
stuff, you can put those in a different folder and then use the assembly or
similar plugin to deal with them.

-Dave

On Thu, Jun 25, 2009 at 2:19 PM, sundar varadarajan
wrote:

> Hello,
>
> I m new to Maven and I m trying to place property and config.xml files
> outside the Jar files. Here is my current directory
>
> Src
>  main
>  java
>  resources
> test
>  java
>  resources
>
> under java, i have all the java class files and in resources folder i have
> the properties and springbatch xml files.
>
> when i package the application, the property files which are under
> src/main/resources is also getting included. I need to place this outside
> the jar file so that the application can pickup when ever i make any
> changes
> to the property. currently i need to package again whenever a small change
> is made.
>
> please help.
>
> Thanks,
> Sundar
>


Maven - Property files Question

2009-06-25 Thread sundar varadarajan
Hello,

I m new to Maven and I m trying to place property and config.xml files
outside the Jar files. Here is my current directory

Src
 main
  java
  resources
test
 java
  resources

under java, i have all the java class files and in resources folder i have
the properties and springbatch xml files.

when i package the application, the property files which are under
src/main/resources is also getting included. I need to place this outside
the jar file so that the application can pickup when ever i make any changes
to the property. currently i need to package again whenever a small change
is made.

please help.

Thanks,
Sundar