You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by LinaTomy <lt...@taxcient.com> on 2007/11/30 20:48:13 UTC

Maven install

Hi
         I have the following structure

src
  |
  ---main
            |
             ----resources
                                |
                                ---
                                    A.properties
                                    store
                                            |
                                             ----
                                                   1.pdf
                                                   2.pdf
                                                   data
                                                         |
                                                         ---
                                                            1.xml
                                                            2.xml

When i do a maven install I need the following to happen

1. Filter only A.properties
2. Do not filter any files under store
3. Copy store to classes
4. Do not copy store to war
5. Copy filtered properties to both war and classes

Also when I do a mvn install the properties files which is copied to war is
not able to get the value for ${project.build.outputDirectory}. 

Could someone please help me with this. 

Below is my pom's snippet

<build>

<plugins> 
	<plugin> 
	<groupId>org.apache.maven.plugins</groupId> 
	<artifactId>maven-war-plugin</artifactId> 
	<version>2.0.2</version> 
	<configuration> 
		<webResources>
			<resource>
				<directory>src/main/resources</directory>
				<targetPath>WEB-INF/classes</targetPath>
				<!-- Filter the properties file to replace varibles with appropriate
values -->
				<filtering>true</filtering>
				<includes>
					<include>*.properties</include>
				</includes>
			</resource>
		</webResources>
	</configuration> 
	</plugin> 
</plugins> 
 
<!-- turn filtering on for the project's resources directory -->	
<resources>
	<resource>
		<directory>src/main/resources</directory>
		<!-- Filter the properties file to replace varibles with appropriate
values -->
		<filtering>true</filtering>
                <includes>
		  <include>*.properties</include>
		</includes>
		<excludes>
                  <exclude>*.pdf</exclude>
                  <exclude>*.xml</exclude>
                 </excludes>
	</resource>
</resources> 
 
</build>
-- 
View this message in context: http://www.nabble.com/Maven-install-tf4923928s177.html#a14091357
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Maven install

Posted by LinaTomy <lt...@taxcient.com>.
Thanks a lot for detailed reply.

I'll elaborate what I want to achieve

1. I need to filter A.properties. This file has a property
name={filtered.name} that needs to be filtered with a default value at all
times except when generating a war for deployment on an application server.
This file is directly under src/main/resources. 

For this I have the following configured in pom.xml 

<plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
                <webResources>
                        <resource>
                                <directory>src/main/resources</directory>
                                <targetPath>WEB-INF/classes</targetPath>
                                <!-- Filter the properties file to replace
varibles with appropriate values -->
                                <filtering>true</filtering>
                                <includes>
                                        <include>*.properties</include>
                                </includes>
                        </resource>
                </webResources>
        </configuration>
        </plugin>
</plugins> 

<!-- turn filtering on for the project's resources directory -->
<resources>
        <resource>
                <directory>src/main/resources</directory>
                <!-- Filter the properties file to replace varibles with
appropriate values -->
                <filtering>true</filtering>
                <includes>
                  <include>*.properties</include>
                </includes>
        </resource>
</resources> 

2. I also have a folder store under src/main/resources. I want to copy this
to my default output directory classes directory where my compiled classes
reside, which I know is the common behavior.  But I do not want to filter
any files under this folder. 

I added this to the configuration for attaining this

<!-- turn filtering on for the project's resources directory -->
<resources>
        <resource>
                <directory>src/main/resources</directory>
                <!-- Filter the properties file to replace varibles with
appropriate values -->
                <filtering>true</filtering>
                <includes>
                  <include>*.properties</include>
                </includes>
                <excludes>
                  <exclude>*.pdf</exclude>
                  <exclude>*.xml</exclude>
                 </excludes>
        </resource>
</resources> 

But the files under the folder store still gets filtered. 

3 and 4. I need the folder store in the classes directory on my local
development machine for running the application locally, but then I do not
need it in the war file for deployment on the application server coz it
there is a different location for that directory on the server which is what
the value that is in the properties file that is being filtered pertains to. 

5. When i say war and classes, I mean classes folder on my development
machine and war file created for deployment. So the classes folder in the
war generated doesn't need the store folder under src/main/resources. 

I always do a mvn install for building my application. When I need to
generate a war for deployment I do mvn install -P <name of profile with
values for filtering>

1 - is your project  a .war project
   Yes it is a war project. It is bundled as a jar when deployed. I run it
from my IDE when on local which  is why i don't use the bundle when
developing. I jus access the classes folder thats generated from the build. 
2 - if you have resources that need filtering and some others that don't,
why don't you use ${} in resources that must be filtered and leave plain
text in resources that don't need to be filtered ?
   Thats what I have done i the properties file and that part works fine. 
3 - what do you mean by .war and .classes? are we talking about same
project? 
     Sorry, but i was referring to the classes folder in the output
directory and the classes folder in the war package. 

Thanks a bunch for this excellent reply though. I'm sorry I had not made
everything as clear as it should have been
-- 
View this message in context: http://www.nabble.com/Maven-install-tf4923928s177.html#a14134623
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Maven install

Posted by Marco Mistroni <mm...@gmail.com>.
Hi ,
 let's start from what you want to achieve:
1. Filter only A.properties

First off, how many files need filtering?
If you need only A.properties (in whole application), the
A.propertiesshould be the only one which contains ${
your.property) tags.
If you have also B.properties that contains ${} and you don't want to filter
it, then when it will be copied in the \target\classes directory that file
will end up with still ${} tags.

2. Do not filter any files under store
you can still specify that under the <resources> xml tag. you will
have(Pseudocode) <resource><dir><filtering>true</filtering></dir><resource>
as well as <resource> dir2 <filtering>false</filtering>
3. Copy store to classes
if store is under src/main/resources, it will be copied automatically to
\classes
4. Do not copy store to war
well, store will end up in the \classes directory of your war file... i see
nothing wrong with that. if your \classes is part of building war...
5. Copy filtered properties to both war and classes
?
why you are mentioning \war  and \classes

is your project building a  \war? if so, then when the war will be
assembled, \classes directory will be part of it..

could you elaborate more if your project is a .war or .jar or so mething
else?>
i have plenty of projects i m doing that are building wars, using resources
and filtering.......
please provide answer to this question and i could help more

1 - is your project  a .war project
2 - if you have resources taht need filtering and some others that don't,
why don't you use ${} in resources taht must be filtered and leave plain
text in resources that don't need to be filtered ?
3 - what do you mean by .war and .classes? are we talking about same
project?


regards
 marco

On Nov 30, 2007 11:11 PM, LinaTomy <lt...@taxcient.com> wrote:

>
> Its in my settings.xml. The ones there are the defaults.
>
> I have a profile in profiles.xml which is not active by default. I only
> use
> that with the -P switch when i do an install for generating a war fro my
> deployment.
>
>
> mmistroni wrote:
> >
> > Hi,
> >    where are your properties(i mean the 'replacement' properties)
> > 'stored'?
> > in your profile?
> >
> > On Nov 30, 2007 7:48 PM, LinaTomy <lt...@taxcient.com> wrote:
> >
> >>
> >> Hi
> >>         I have the following structure
> >>
> >> src
> >>  |
> >>  ---main
> >>            |
> >>             ----resources
> >>                                |
> >>                                ---
> >>                                    A.properties
> >>                                    store
> >>                                            |
> >>                                             ----
> >>                                                   1.pdf
> >>                                                   2.pdf
> >>                                                   data
> >>                                                         |
> >>                                                         ---
> >>                                                            1.xml
> >>                                                            2.xml
> >>
> >> When i do a maven install I need the following to happen
> >>
> >> 1. Filter only A.properties
> >> 2. Do not filter any files under store
> >> 3. Copy store to classes
> >> 4. Do not copy store to war
> >> 5. Copy filtered properties to both war and classes
> >>
> >> Also when I do a mvn install the properties files which is copied to
> war
> >> is
> >> not able to get the value for ${project.build.outputDirectory}.
> >>
> >> Could someone please help me with this.
> >>
> >> Below is my pom's snippet
> >>
> >> <build>
> >>
> >> <plugins>
> >>        <plugin>
> >>        <groupId>org.apache.maven.plugins</groupId>
> >>        <artifactId>maven-war-plugin</artifactId>
> >>        <version>2.0.2</version>
> >>        <configuration>
> >>                <webResources>
> >>                        <resource>
> >>
>  <directory>src/main/resources</directory>
> >>                                <targetPath>WEB-INF/classes</targetPath>
> >>                                <!-- Filter the properties file to
> replace
> >> varibles with appropriate
> >> values -->
> >>                                <filtering>true</filtering>
> >>                                <includes>
> >>                                        <include>*.properties</include>
> >>                                </includes>
> >>                        </resource>
> >>                </webResources>
> >>        </configuration>
> >>        </plugin>
> >> </plugins>
> >>
> >> <!-- turn filtering on for the project's resources directory -->
> >> <resources>
> >>        <resource>
> >>                <directory>src/main/resources</directory>
> >>                <!-- Filter the properties file to replace varibles with
> >> appropriate
> >> values -->
> >>                <filtering>true</filtering>
> >>                <includes>
> >>                  <include>*.properties</include>
> >>                </includes>
> >>                <excludes>
> >>                  <exclude>*.pdf</exclude>
> >>                  <exclude>*.xml</exclude>
> >>                 </excludes>
> >>        </resource>
> >> </resources>
> >>
> >> </build>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Maven-install-tf4923928s177.html#a14091357
> >> Sent from the Maven - Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Maven-install-tf4923928s177.html#a14097129
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven install

Posted by LinaTomy <lt...@taxcient.com>.
Its in my settings.xml. The ones there are the defaults. 

I have a profile in profiles.xml which is not active by default. I only use
that with the -P switch when i do an install for generating a war fro my
deployment. 


mmistroni wrote:
> 
> Hi,
>    where are your properties(i mean the 'replacement' properties) 
> 'stored'?
> in your profile?
> 
> On Nov 30, 2007 7:48 PM, LinaTomy <lt...@taxcient.com> wrote:
> 
>>
>> Hi
>>         I have the following structure
>>
>> src
>>  |
>>  ---main
>>            |
>>             ----resources
>>                                |
>>                                ---
>>                                    A.properties
>>                                    store
>>                                            |
>>                                             ----
>>                                                   1.pdf
>>                                                   2.pdf
>>                                                   data
>>                                                         |
>>                                                         ---
>>                                                            1.xml
>>                                                            2.xml
>>
>> When i do a maven install I need the following to happen
>>
>> 1. Filter only A.properties
>> 2. Do not filter any files under store
>> 3. Copy store to classes
>> 4. Do not copy store to war
>> 5. Copy filtered properties to both war and classes
>>
>> Also when I do a mvn install the properties files which is copied to war
>> is
>> not able to get the value for ${project.build.outputDirectory}.
>>
>> Could someone please help me with this.
>>
>> Below is my pom's snippet
>>
>> <build>
>>
>> <plugins>
>>        <plugin>
>>        <groupId>org.apache.maven.plugins</groupId>
>>        <artifactId>maven-war-plugin</artifactId>
>>        <version>2.0.2</version>
>>        <configuration>
>>                <webResources>
>>                        <resource>
>>                                <directory>src/main/resources</directory>
>>                                <targetPath>WEB-INF/classes</targetPath>
>>                                <!-- Filter the properties file to replace
>> varibles with appropriate
>> values -->
>>                                <filtering>true</filtering>
>>                                <includes>
>>                                        <include>*.properties</include>
>>                                </includes>
>>                        </resource>
>>                </webResources>
>>        </configuration>
>>        </plugin>
>> </plugins>
>>
>> <!-- turn filtering on for the project's resources directory -->
>> <resources>
>>        <resource>
>>                <directory>src/main/resources</directory>
>>                <!-- Filter the properties file to replace varibles with
>> appropriate
>> values -->
>>                <filtering>true</filtering>
>>                <includes>
>>                  <include>*.properties</include>
>>                </includes>
>>                <excludes>
>>                  <exclude>*.pdf</exclude>
>>                  <exclude>*.xml</exclude>
>>                 </excludes>
>>        </resource>
>> </resources>
>>
>> </build>
>> --
>> View this message in context:
>> http://www.nabble.com/Maven-install-tf4923928s177.html#a14091357
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Maven-install-tf4923928s177.html#a14097129
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Maven install

Posted by Marco Mistroni <mm...@gmail.com>.
Hi,
   where are your properties(i mean the 'replacement' properties)  'stored'?
in your profile?

On Nov 30, 2007 7:48 PM, LinaTomy <lt...@taxcient.com> wrote:

>
> Hi
>         I have the following structure
>
> src
>  |
>  ---main
>            |
>             ----resources
>                                |
>                                ---
>                                    A.properties
>                                    store
>                                            |
>                                             ----
>                                                   1.pdf
>                                                   2.pdf
>                                                   data
>                                                         |
>                                                         ---
>                                                            1.xml
>                                                            2.xml
>
> When i do a maven install I need the following to happen
>
> 1. Filter only A.properties
> 2. Do not filter any files under store
> 3. Copy store to classes
> 4. Do not copy store to war
> 5. Copy filtered properties to both war and classes
>
> Also when I do a mvn install the properties files which is copied to war
> is
> not able to get the value for ${project.build.outputDirectory}.
>
> Could someone please help me with this.
>
> Below is my pom's snippet
>
> <build>
>
> <plugins>
>        <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-war-plugin</artifactId>
>        <version>2.0.2</version>
>        <configuration>
>                <webResources>
>                        <resource>
>                                <directory>src/main/resources</directory>
>                                <targetPath>WEB-INF/classes</targetPath>
>                                <!-- Filter the properties file to replace
> varibles with appropriate
> values -->
>                                <filtering>true</filtering>
>                                <includes>
>                                        <include>*.properties</include>
>                                </includes>
>                        </resource>
>                </webResources>
>        </configuration>
>        </plugin>
> </plugins>
>
> <!-- turn filtering on for the project's resources directory -->
> <resources>
>        <resource>
>                <directory>src/main/resources</directory>
>                <!-- Filter the properties file to replace varibles with
> appropriate
> values -->
>                <filtering>true</filtering>
>                <includes>
>                  <include>*.properties</include>
>                </includes>
>                <excludes>
>                  <exclude>*.pdf</exclude>
>                  <exclude>*.xml</exclude>
>                 </excludes>
>        </resource>
> </resources>
>
> </build>
> --
> View this message in context:
> http://www.nabble.com/Maven-install-tf4923928s177.html#a14091357
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>