You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by jeb001 <je...@gmail.com> on 2010/11/09 14:37:05 UTC

Eclipse multi-module project with maven

Hi,

I'm a new user of maven.. I've seen part of response at my question, but
never exactly got
what I expect.
So, before introducing maven into my project, I had 3 differents projects.
The Api, a batch project, and a web project. 
Both web and batch project needs the api.jar to compile. 

So, I've made a maven project including my API project.
In the pom.xml, I just added 2 modules (web and batch).

I understood that with maven, it's better to include the project'son into
the parent. 
I've got now one project including web and batch project.
It's seems to work, when I build it, the batch project make a jar file, and
the web one make a war file.

The problem is right here : both sons project are not compiled. Maybe should
I add them to the eclipse build path ? I don't really know what' the way...

Thx for your help

-- 
View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256822.html
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: Eclipse multi-module project with maven

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/9 jeb001 <je...@gmail.com>:
> In my case, web and batch project needs Api jar file to work.. but, I should
> not consider the Api project as the parent ?

No, it's a dependency.

> By the way, if create one aggregating Maven project listing 3 modules..
> should I declare the sourceFolder in the eclipse classPath ?

Do it in every single module or, better, use the standard directory
(src/main/java).

Antonio

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


Re: Eclipse multi-module project with maven

Posted by jeb001 <je...@gmail.com>.
Ok, Thanks for all.. I think that I should let the static configuration on
the server,
and don't care about it when I package... 

Thx,

Jeremy
-- 
View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3265745.html
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: Eclipse multi-module project with maven

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/10 jeb001 <je...@gmail.com>:
> I've seen that I should use profiles et filters.. but I don't know exactly
> how, with my 4-part project?
>
> In which pom.xml have I to define thoses filters ? each one ?
> I'm not sure this is the best way to do it..

Yes, each one you have such configurable resources.
1. Just create all your profiles and, in each profile, put specific properties.
2. Replace all the addresses in your resources with ${...}
placeholders connected to the property you defined in your poms.
3. Instruct Maven to filter resources (filtering is off by default):

        <resources>
        	<resource>
        		<filtering>true</filtering>
        		<directory>src/main/resources</directory>
        	</resource>
        </resources>

As an option, you can think of *not* putting addresses in pom.xml, but
inside your settings.xml and activated by specific profiles.
However, take in consideration what I said before: leave this kind of
configuration on the server itself.

HTH
Antonio

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


Re: Eclipse multi-module project with maven

Posted by jeb001 <je...@gmail.com>.
You're right, those 2 set of resources only differ in the addresses they
point. (or something like that..)

I've seen that I should use profiles et filters.. but I don't know exactly
how, with my 4-part project?

In which pom.xml have I to define thoses filters ? each one ? 
I'm not sure this is the best way to do it.. 

-- 
View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3258445.html
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: Eclipse multi-module project with maven

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/10 jeb001 <je...@gmail.com>:
> Now, I'm looking for the best way to use maven profiles with my new project
> organisation..
> I just wanna create 2 profiles, developpement and production, for each
> project.
> The production profile will have to package using src/main/resources-prod
> directory, and thes
> developpements one will package with the src/main/resources-dev directory..

Just curious, what are the differences between these two sets of resources?
My best bet is that they differ in the addresses they point with
essentially the same structure.
If this is the case, you can filter your resources, using profiles
only to add properties:
http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
If you have a more complicated configuration, take a look at this:
http://code.google.com/p/maven-config-processor-plugin/

Anyway the best option is to leave this kind of server-specific
configuration on the server itself. For example, in JBoss under the
directory:
<jboss>/server/<myserver>/conf
The files put there are accessible by Class.getResource

Antonio

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


Re: Eclipse multi-module project with maven

Posted by jeb001 <je...@gmail.com>.
Ok, that works the way I want... with 4 eclipse projects and only 3 real
ones.

Now, I'm looking for the best way to use maven profiles with my new project
organisation..
I just wanna create 2 profiles, developpement and production, for each
project.
The production profile will have to package using src/main/resources-prod
directory, and thes 
developpements one will package with the src/main/resources-dev directory..

In wich pom file should I create those profiles ? in the aggreagating
project ? Wher should I put the resources directories ??

thanks for your help.

Jeremy
-- 
View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3258363.html
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: Eclipse multi-module project with maven

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 09/11/2010 9:09 AM, Anders Hammar wrote:
> Yes, a parent is a pom project. Your api project is a jar project - it
> creates a jar.
>
> So create an aggregating project which can also be the parent project. Then
> create three jar projects, which are listed as modules.
> There are create resources on the Internet explaining all this.
>
> Regarding Eclipse: use m2eclipse and it will take care of everything for
> you.
Eclipse STS includes maven integration and is also a good IDE for use 
with Maven.

> /Anders
>
> On Tue, Nov 9, 2010 at 15:05, jeb001<je...@gmail.com>  wrote:
>
>> Ok, I guess there's a confusion speaking about "parent" project..
>>
>> In my case, web and batch project needs Api jar file to work.. but, I
>> should
>> not consider the Api project as the parent ?
>>
>> By the way, if create one aggregating Maven project listing 3 modules..
>> should I declare the sourceFolder in the eclipse classPath ?
>>
>> --
>> View this message in context:
>> http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256876.html
>> 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
>>
>>


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


Re: Eclipse multi-module project with maven

Posted by jeb001 <je...@gmail.com>.
Ok, there's no hierarchy in a parent project..

I try to apply your recommendations, thanks for your help,

Jeremy.

-- 
View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256891.html
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: Eclipse multi-module project with maven

Posted by Anders Hammar <an...@hammar.net>.
Yes, a parent is a pom project. Your api project is a jar project - it
creates a jar.

So create an aggregating project which can also be the parent project. Then
create three jar projects, which are listed as modules.
There are create resources on the Internet explaining all this.

Regarding Eclipse: use m2eclipse and it will take care of everything for
you.

/Anders

On Tue, Nov 9, 2010 at 15:05, jeb001 <je...@gmail.com> wrote:

>
> Ok, I guess there's a confusion speaking about "parent" project..
>
> In my case, web and batch project needs Api jar file to work.. but, I
> should
> not consider the Api project as the parent ?
>
> By the way, if create one aggregating Maven project listing 3 modules..
> should I declare the sourceFolder in the eclipse classPath ?
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256876.html
> 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: Eclipse multi-module project with maven

Posted by jeb001 <je...@gmail.com>.
Ok, I guess there's a confusion speaking about "parent" project.. 

In my case, web and batch project needs Api jar file to work.. but, I should
not consider the Api project as the parent ?

By the way, if create one aggregating Maven project listing 3 modules..
should I declare the sourceFolder in the eclipse classPath ?

-- 
View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256876.html
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: Eclipse multi-module project with maven

Posted by Anders Hammar <an...@hammar.net>.
You should create one aggregating Maven project, which is a pom project
which lists your three modules (api, batch, and web).
Then, in the sub-folders stated by your module names, create the Maven
projects that will be creating your jars.

So, in total you will have four Maven projects. This is what's called a
multi-module project which is explained in many places on the Internet.

/Anders

On Tue, Nov 9, 2010 at 14:37, jeb001 <je...@gmail.com> wrote:

>
> Hi,
>
> I'm a new user of maven.. I've seen part of response at my question, but
> never exactly got
> what I expect.
> So, before introducing maven into my project, I had 3 differents projects.
> The Api, a batch project, and a web project.
> Both web and batch project needs the api.jar to compile.
>
> So, I've made a maven project including my API project.
> In the pom.xml, I just added 2 modules (web and batch).
>
> I understood that with maven, it's better to include the project'son into
> the parent.
> I've got now one project including web and batch project.
> It's seems to work, when I build it, the batch project make a jar file, and
> the web one make a war file.
>
> The problem is right here : both sons project are not compiled. Maybe
> should
> I add them to the eclipse build path ? I don't really know what' the way...
>
> Thx for your help
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256822.html
> 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: Eclipse multi-module project with maven

Posted by Anders Hammar <an...@hammar.net>.
Keep your aggregating project clean. Move you build stuff to a separate
module.

/Anders

On Tue, Nov 9, 2010 at 15:02, jeb001 <je...@gmail.com> wrote:

>
> sure, here it is :
>
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>        <modelVersion>4.0.0</modelVersion>
>        <groupId>fr.gouv.finances.douane.dnsce.mavenProject</groupId>
>        <artifactId>MavenProject</artifactId>
>        <version>1.0.2-SNAPSHOT</version>
>        <packaging>pom</packaging>
>        <name>MavenProject</name>
>
>        <dependencies>
>                <!-- dependencies -->
>        </dependencies>
>
>        <build>
>
>                <resources>
>                        <resource>
>                                <directory>${basedir}/conf</directory>
>                        </resource>
>                </resources>
>                <testResources>
>                        <testResource>
>                                <directory>${basedir}/confTest</directory>
>                        </testResource>
>                </testResources>
>
>
>  <testSourceDirectory>${basedir}/JunitSources</testSourceDirectory>
>                <outputDirectory>${basedir}/classes</outputDirectory>
>
>  <testOutputDirectory>${basedir}/classes</testOutputDirectory>
>                <plugins>
>                        <plugin>
>                                <groupId>org.codehaus.mojo</groupId>
>
>  <artifactId>build-helper-maven-plugin</artifactId>
>                                <version>1.5</version>
>                                <executions>
>                                        <execution>
>
>  <phase>generate-sources</phase>
>                                                <goals>
>
>  <goal>add-source</goal>
>                                                </goals>
>                                                <configuration>
>                                                        <sources>
>
>  <source>${basedir}/IbatisSources</source>
>
>  <source>${basedir}/PersistanceSources</source>
>
>  <source>${basedir}/JavaSources</source>
>                                                        </sources>
>                                                </configuration>
>                                        </execution>
>                                </executions>
>                        </plugin>
>                        <plugin>
>
>  <artifactId>maven-compiler-plugin</artifactId>
>                                <version>2.3.1</version>
>                                <configuration>
>                                        <source>1.5</source>
>                                        <target>1.5</target>
>                                </configuration>
>                        </plugin>
>                </plugins>
>        </build>
>
>  <modules>
>    <module>MavenBatch</module>
>    <module>MavenWeb</module>
>  </modules>
>
> </project>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256864.html
> 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: Eclipse multi-module project with maven

Posted by jeb001 <je...@gmail.com>.
sure, here it is :


<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>fr.gouv.finances.douane.dnsce.mavenProject</groupId>
	<artifactId>MavenProject</artifactId>
	<version>1.0.2-SNAPSHOT</version>
	<packaging>pom</packaging>
	<name>MavenProject</name>

	<dependencies>
		<!-- dependencies -->			
	</dependencies>

	<build>
		
		<resources>
			<resource>
				<directory>${basedir}/conf</directory>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>${basedir}/confTest</directory>
			</testResource>
		</testResources>

		<testSourceDirectory>${basedir}/JunitSources</testSourceDirectory>
		<outputDirectory>${basedir}/classes</outputDirectory>
		<testOutputDirectory>${basedir}/classes</testOutputDirectory>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>${basedir}/IbatisSources</source>								
								<source>${basedir}/PersistanceSources</source>
								<source>${basedir}/JavaSources</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.1</version>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
				</configuration>
			</plugin>
		</plugins>
	</build>

  <modules>
    <module>MavenBatch</module>        
    <module>MavenWeb</module>
  </modules>
  
</project>
-- 
View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256864.html
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: Eclipse multi-module project with maven

Posted by Greg Akins <an...@gmail.com>.
Could you show us the contents of the parent pom.xml?

On Tue, Nov 9, 2010 at 8:37 AM, jeb001 <je...@gmail.com> wrote:
>
> Hi,
>
> I'm a new user of maven.. I've seen part of response at my question, but
> never exactly got
> what I expect.
> So, before introducing maven into my project, I had 3 differents projects.
> The Api, a batch project, and a web project.
> Both web and batch project needs the api.jar to compile.
>
> So, I've made a maven project including my API project.
> In the pom.xml, I just added 2 modules (web and batch).
>
> I understood that with maven, it's better to include the project'son into
> the parent.
> I've got now one project including web and batch project.
> It's seems to work, when I build it, the batch project make a jar file, and
> the web one make a war file.
>
> The problem is right here : both sons project are not compiled. Maybe should
> I add them to the eclipse build path ? I don't really know what' the way...
>
> Thx for your help
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Eclipse-multi-module-project-with-maven-tp3256822p3256822.html
> 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
>
>



-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

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