You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mauro Dragoni <ma...@gmail.com> on 2012/08/20 21:19:51 UTC

classes developed in a sub-modules does not see packages defined in other ones

Good morning to everyone.
I am quite new to Maven and I have a problem that I am not able to solve.
I have my project structured in this way:

main_module
|--- module_1
|--- module_2
|--- module_3

and for each module I have created its pom.xml file.
I have the following questions:
1) I saw that in the main_module there is not any folder for putting
the source code file, but from the manual I read that it is right
because it has been created as main project. Is it right?
2) I have defined a package in "module_1" that I would like to re-use
in "module_2", but it does not see it. How can I do this?

Thanks in advance for any help.
Have a nice day.

Mauro.

-- 
Dr. Mauro Dragoni
Ph.D. in Computer Science.
Post-Doc Researcher at Fondazione Bruno Kessler (FBK-IRST), Trento, Italy.

My Research Site: https://dkm.fbk.eu/index.php/Mauro_Dragoni
My Business Site: http://www.dragotechpro.com
My News-Project Site: http://www.dragotimes.com


Confidentially Notice. This electronic mail transmission may contain
legally privileged and/or confidential information. Do not read this,
if you are not the person named to.
Any use, distribution, copying or disclosure by any other person is
strictly prohibited.
If you received this transmission in error, please notify the sender
and delete the original transmission and its attachments without
reading or saving it in any manner.

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


Re: classes developed in a sub-modules does not see packages defined in other ones

Posted by Mauro Dragoni <ma...@gmail.com>.
Thank you very much guys.
I've created a dependency in the pom.xml of the module_2 that uses the
package defined in the module_1 and it works well.
I don't know if it is the most efficient solution, but for now it is ok... ;)

This Maven is a bit complex at the beginning, but it is very
attractive when different development teams work together... :)
Have a nice day.

Mauro.


On Mon, Aug 20, 2012 at 9:30 PM, Brian Topping <to...@codehaus.org> wrote:
> Hi Mauro,
>
> You are very close, just need one dependency defined in the POM for module_2 to module_1.  So assuming you created everything with the Maven project archetypes, you'll have some examples of dependencies in your POMs for jUnit, just duplicate one of those in module_2 and change the GAV (group, artifact, version) to the GAV of module_1 (defined at the top of that file).
>
> What you call the main_module is really just a means of project inheritance and containment, it has no artifacts other than the POM itself.  POM packaging projects such as this are called "aggregator" projects in the documentation.
>
> Hope that helps, welcome to Maven!
>
> Brian
>
> On Aug 20, 2012, at 10:19 PM, Mauro Dragoni <ma...@gmail.com> wrote:
>
>> Good morning to everyone.
>> I am quite new to Maven and I have a problem that I am not able to solve.
>> I have my project structured in this way:
>>
>> main_module
>> |--- module_1
>> |--- module_2
>> |--- module_3
>>
>> and for each module I have created its pom.xml file.
>> I have the following questions:
>> 1) I saw that in the main_module there is not any folder for putting
>> the source code file, but from the manual I read that it is right
>> because it has been created as main project. Is it right?
>> 2) I have defined a package in "module_1" that I would like to re-use
>> in "module_2", but it does not see it. How can I do this?
>>
>> Thanks in advance for any help.
>> Have a nice day.
>>
>> Mauro.
>>
>> --
>> Dr. Mauro Dragoni
>> Ph.D. in Computer Science.
>> Post-Doc Researcher at Fondazione Bruno Kessler (FBK-IRST), Trento, Italy.
>>
>> My Research Site: https://dkm.fbk.eu/index.php/Mauro_Dragoni
>> My Business Site: http://www.dragotechpro.com
>> My News-Project Site: http://www.dragotimes.com
>>
>>
>> Confidentially Notice. This electronic mail transmission may contain
>> legally privileged and/or confidential information. Do not read this,
>> if you are not the person named to.
>> Any use, distribution, copying or disclosure by any other person is
>> strictly prohibited.
>> If you received this transmission in error, please notify the sender
>> and delete the original transmission and its attachments without
>> reading or saving it in any manner.
>>
>> ---------------------------------------------------------------------
>> 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
>



-- 
Dr. Mauro Dragoni
Ph.D. in Computer Science.
Post-Doc Researcher at Fondazione Bruno Kessler (FBK-IRST), Trento, Italy.

My Research Site: https://dkm.fbk.eu/index.php/Mauro_Dragoni
My Business Site: http://www.dragotechpro.com
My News-Project Site: http://www.dragotimes.com


Confidentially Notice. This electronic mail transmission may contain
legally privileged and/or confidential information. Do not read this,
if you are not the person named to.
Any use, distribution, copying or disclosure by any other person is
strictly prohibited.
If you received this transmission in error, please notify the sender
and delete the original transmission and its attachments without
reading or saving it in any manner.

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


Re: classes developed in a sub-modules does not see packages defined in other ones

Posted by Brian Topping <to...@codehaus.org>.
Hi Mauro,

You are very close, just need one dependency defined in the POM for module_2 to module_1.  So assuming you created everything with the Maven project archetypes, you'll have some examples of dependencies in your POMs for jUnit, just duplicate one of those in module_2 and change the GAV (group, artifact, version) to the GAV of module_1 (defined at the top of that file). 

What you call the main_module is really just a means of project inheritance and containment, it has no artifacts other than the POM itself.  POM packaging projects such as this are called "aggregator" projects in the documentation.

Hope that helps, welcome to Maven!

Brian

On Aug 20, 2012, at 10:19 PM, Mauro Dragoni <ma...@gmail.com> wrote:

> Good morning to everyone.
> I am quite new to Maven and I have a problem that I am not able to solve.
> I have my project structured in this way:
> 
> main_module
> |--- module_1
> |--- module_2
> |--- module_3
> 
> and for each module I have created its pom.xml file.
> I have the following questions:
> 1) I saw that in the main_module there is not any folder for putting
> the source code file, but from the manual I read that it is right
> because it has been created as main project. Is it right?
> 2) I have defined a package in "module_1" that I would like to re-use
> in "module_2", but it does not see it. How can I do this?
> 
> Thanks in advance for any help.
> Have a nice day.
> 
> Mauro.
> 
> -- 
> Dr. Mauro Dragoni
> Ph.D. in Computer Science.
> Post-Doc Researcher at Fondazione Bruno Kessler (FBK-IRST), Trento, Italy.
> 
> My Research Site: https://dkm.fbk.eu/index.php/Mauro_Dragoni
> My Business Site: http://www.dragotechpro.com
> My News-Project Site: http://www.dragotimes.com
> 
> 
> Confidentially Notice. This electronic mail transmission may contain
> legally privileged and/or confidential information. Do not read this,
> if you are not the person named to.
> Any use, distribution, copying or disclosure by any other person is
> strictly prohibited.
> If you received this transmission in error, please notify the sender
> and delete the original transmission and its attachments without
> reading or saving it in any manner.
> 
> ---------------------------------------------------------------------
> 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: classes developed in a sub-modules does not see packages defined in other ones

Posted by John Kramer <jk...@mojiva.com>.
Hi Mauro,

Perhaps I can shed some light on these questions:

1) I saw that in the main_module there is not any folder for putting
the source code file, but from the manual I read that it is right
because it has been created as main project. Is it right?

In the case you have described main_module should have no build artifacts
associated with it other than a pom file.  It is a container rather than
anything that produces production, test, or documentation artifacts.  It's
type should be pom.  There should be a section in main_module that tells
maven to build the submodules.

The other modules (in this case module_1, module_2, and module_3) should
produce production, test, or documentation artifacts.  Their types might
be jar, war, ear, etc.


2) I have defined a package in "module_1" that I would like to re-use
in "module_2", but it does not see it. How can I do this?


You should add a dependency on module_1 in module_2's pom.

Check out the following links for some guidance on multi module projects:


http://maven.apache.org/guides/mini/guide-multiple-modules.html
http://www.sonatype.com/books/mvnex-book/reference/multimodule.html


John Kramer
email: jkramer@mojiva.com
mobile: 314.435.2370
skype: kramer.mojiva
twitter: @KramerKnowsTech <https://twitter.com/KramerKnowsTech>
0xCAFEBABE00000032


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