You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Nicholas Tung <nt...@ntung.com> on 2009/07/22 05:34:22 UTC

help with multi-module build

Hi all,

   I'm having trouble getting a multi-module project to build. What I want
to do is simple: build a Scala compiler plugin (jar), and then compile the
rest of the project using that.

   Right now, I have two proxy modules (building things in ../src),
"myproj-plugin" and "myproj-base". The first builds only the plugin, using
an assembly to build the jar file -- the output looks fine (though the name
is a bit long, and I'm not sure how to properly address it). However, when
"myproj-base" builds, I get "unable to find resource <plugin resource>" [1],
and it tries downloading "myproj-plugin" from the Scala and Maven
repositories (ick). I tried specifying the jar name path with "systemPath",
but no luck.

    If possible, I'd like it to be able to

   - rebuild all Scala files in "myproj-base" when the plugin changes (to
   make sure the plugin doesn't break anything).
   - build the entire project by typing "mvn compile" in the base directory
   (from scratch).

    The full project source is at [2].

Thanks in advance,
Nicholas

btw. spam filter is giving me bouncebacks even though I am registered on the
list.




[1]

[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] wrap: org.apache.maven.artifact.resolver.ArtifactNotFoundException:
Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command:

[2]
http://github.com/gatoatigrado/skalch/commit/cb258d39c0dc796de8f6c1076e05505bb21f854a

Re: help with multi-module build

Posted by Nicholas Tung <ga...@gmail.com>.
On Tue, Jul 21, 2009 at 10:47 PM, Nicholas Tung <ga...@gmail.com>wrote:

> On Tue, Jul 21, 2009 at 10:21 PM, David C. Hicks <dh...@i-hicks.org>wrote:
>
>> One of the tenets of Maven is to create one artifact for each module.
>> Combining your source in the same directory tree violates that tenet.
>> I'm sure you can probably force Maven to do it, but it won't like it.
>> When you specify the <modules> you are essentially telling Maven to look
>> for pom.xml files in those sub-directories.
>
>
> Right... I moved the plugin code to its own subdirectory [1], but no
> difference (I agree it's cleaner though).
>
> It's possible that using "mvn compile" could be part of your problem.
>> When you only run the "compile" goal, you don't get to the "package"
>> goal, which is when the jar file would be created.
>
>
> I tried "package", and only "install" seems to have the correct effect of
> building the jar file. I suppose it's probably not going to hurt to install
> versus package... it just seems weird.
>
> After I do that, I get some "NoSuchElementException" from scala, but I'm
> guessing that's the scala maven plugin's fault. The jar appears to be
> correct.
>

yeah, I'm pretty sure it's maven-scala's fault [1]. unfortunately I can't
build 2.12 from github due to some dependency problems.

The original problem of "execute `mvn package` for one module to compile
another" would be interesting to solve, but I think the above is a more
critical issue...

Thanks for your help,
Nicholas

[1]
version 2.10 gives
-Xplugin:/home/gatoatigrado/.m2/repository/org/scala-tools/maven-scala-plugin/2.10/maven-scala-plugin-2.10.jar

version 2.11 gives
-Xplugin:/home/gatoatigrado/.m2/repository/xom/xom/1.1/xom-1.1.jar

the correct version should be
-Xplugin:/home/gatoatigrado/.m2/repository/edu/berkeley/cs/sketch/skalch-plugin/git-master/skalch-plugin-git-master.jar

Re: help with multi-module build

Posted by Nicholas Tung <ga...@gmail.com>.
On Tue, Jul 21, 2009 at 10:21 PM, David C. Hicks <dh...@i-hicks.org> wrote:

> One of the tenets of Maven is to create one artifact for each module.
> Combining your source in the same directory tree violates that tenet.
> I'm sure you can probably force Maven to do it, but it won't like it.
> When you specify the <modules> you are essentially telling Maven to look
> for pom.xml files in those sub-directories.


Right... I moved the plugin code to its own subdirectory [1], but no
difference (I agree it's cleaner though).

It's possible that using "mvn compile" could be part of your problem.
> When you only run the "compile" goal, you don't get to the "package"
> goal, which is when the jar file would be created.


I tried "package", and only "install" seems to have the correct effect of
building the jar file. I suppose it's probably not going to hurt to install
versus package... it just seems weird.

After I do that, I get some "NoSuchElementException" from scala, but I'm
guessing that's the scala maven plugin's fault. The jar appears to be
correct.

regards,
Nicholas

[1]
http://github.com/gatoatigrado/skalch/commit/5163b21d82736045806adab40d2b607d59e9bfc5



>
>
>
> Nicholas Tung wrote:
> > On Tue, Jul 21, 2009 at 9:47 PM, David C. Hicks <dh...@i-hicks.org>
> wrote:
> >
> >
> >> It's hard to say from your description, but it sounds like you need to
> >> do some serious restructuring of your project.  Here's what I think you
> >> need to have:
> >>
> >> base-of-project/
> >>    pom.xml
> >>
> >>    myproj-plugin/
> >>        pom.xml
> >>        src/main/scala code goes here
> >>
> >>    myproj-base/
> >>        pom.xml
> >>        src/main/other code goes here
> >>
> >
> >
> > This unnecessarily separates java code in myproj-base from myproj-plugin,
> > but sure.
> >
> >
> >
> >> The pom.xml in the base directory would have your <modules> section and
> >> look like this:
> >>
> >>    <modules>
> >>        <module>myproj-plugin</module>
> >>        <module>myproj-base</module>
> >>    </modules>
> >>
> >
> >
> > I'm using this exactly [1]
> >
> >
> >
> >> This is where the pom.xml files in each sub-directory come into play.
> >> The pom.xml in myproj-base would list "myproj-plugin" as a dependency.
> >> You assign the groupId, artifactId, and version to myproj-plugin in the
> >> top of its pom.xml.  Then you can reference that artifact just like you
> >> would any other artifact.  The difference is that Maven knows to find it
> >> inside the reactor during the build.
> >>
> >
> >
> > I'm already doing this as well [2]; thanks anyway though.
> >
> > It is far better to bend your expectations to the way that Maven wants
> >
> >> to work than to try to force it into submitting to the way YOU want to
> >> do things.  Just learn new habits and you will be far happier letting
> >> Maven do all the neat things it does for you for free.
> >>
> >
> >
> > I'm very willing to restructure the project (i.e. move actual locations
> of
> > source files around). However, I don't see any advantage if Maven won't
> do
> > things differently. Will it actually build the jar for one project when I
> > type mvn compile? I am specifying one project as the dependency of
> another
> > using the standard group-artifact-version tags [3].
> >
> > Maven is already correctly building (mvn compile) myproj-plugin before
> > myproj-base. However, it isn't packaging it as a jar for the Maven Scala
> > plugin.
> >
> > Thanks so much,
> > Nicholas
> >
> > [1]
> >
> http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/pom.xml#L43
> > [2]
> >
> http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/skalch-base/pom.xml#L52
> > [3]
> >
> http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/skalch-base/pom.xml#L34
> >
> >
>

Re: help with multi-module build

Posted by "David C. Hicks" <dh...@i-hicks.org>.
One of the tenets of Maven is to create one artifact for each module. 
Combining your source in the same directory tree violates that tenet. 
I'm sure you can probably force Maven to do it, but it won't like it. 
When you specify the <modules> you are essentially telling Maven to look
for pom.xml files in those sub-directories.

It's possible that using "mvn compile" could be part of your problem. 
When you only run the "compile" goal, you don't get to the "package"
goal, which is when the jar file would be created.


Nicholas Tung wrote:
> On Tue, Jul 21, 2009 at 9:47 PM, David C. Hicks <dh...@i-hicks.org> wrote:
>
>   
>> It's hard to say from your description, but it sounds like you need to
>> do some serious restructuring of your project.  Here's what I think you
>> need to have:
>>
>> base-of-project/
>>    pom.xml
>>
>>    myproj-plugin/
>>        pom.xml
>>        src/main/scala code goes here
>>
>>    myproj-base/
>>        pom.xml
>>        src/main/other code goes here
>>     
>
>
> This unnecessarily separates java code in myproj-base from myproj-plugin,
> but sure.
>
>
>   
>> The pom.xml in the base directory would have your <modules> section and
>> look like this:
>>
>>    <modules>
>>        <module>myproj-plugin</module>
>>        <module>myproj-base</module>
>>    </modules>
>>     
>
>
> I'm using this exactly [1]
>
>
>   
>> This is where the pom.xml files in each sub-directory come into play.
>> The pom.xml in myproj-base would list "myproj-plugin" as a dependency.
>> You assign the groupId, artifactId, and version to myproj-plugin in the
>> top of its pom.xml.  Then you can reference that artifact just like you
>> would any other artifact.  The difference is that Maven knows to find it
>> inside the reactor during the build.
>>     
>
>
> I'm already doing this as well [2]; thanks anyway though.
>
> It is far better to bend your expectations to the way that Maven wants
>   
>> to work than to try to force it into submitting to the way YOU want to
>> do things.  Just learn new habits and you will be far happier letting
>> Maven do all the neat things it does for you for free.
>>     
>
>
> I'm very willing to restructure the project (i.e. move actual locations of
> source files around). However, I don't see any advantage if Maven won't do
> things differently. Will it actually build the jar for one project when I
> type mvn compile? I am specifying one project as the dependency of another
> using the standard group-artifact-version tags [3].
>
> Maven is already correctly building (mvn compile) myproj-plugin before
> myproj-base. However, it isn't packaging it as a jar for the Maven Scala
> plugin.
>
> Thanks so much,
> Nicholas
>
> [1]
> http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/pom.xml#L43
> [2]
> http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/skalch-base/pom.xml#L52
> [3]
> http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/skalch-base/pom.xml#L34
>
>   

Re: help with multi-module build

Posted by Nicholas Tung <ga...@gmail.com>.
On Tue, Jul 21, 2009 at 9:47 PM, David C. Hicks <dh...@i-hicks.org> wrote:

> It's hard to say from your description, but it sounds like you need to
> do some serious restructuring of your project.  Here's what I think you
> need to have:
>
> base-of-project/
>    pom.xml
>
>    myproj-plugin/
>        pom.xml
>        src/main/scala code goes here
>
>    myproj-base/
>        pom.xml
>        src/main/other code goes here


This unnecessarily separates java code in myproj-base from myproj-plugin,
but sure.


> The pom.xml in the base directory would have your <modules> section and
> look like this:
>
>    <modules>
>        <module>myproj-plugin</module>
>        <module>myproj-base</module>
>    </modules>


I'm using this exactly [1]


> This is where the pom.xml files in each sub-directory come into play.
> The pom.xml in myproj-base would list "myproj-plugin" as a dependency.
> You assign the groupId, artifactId, and version to myproj-plugin in the
> top of its pom.xml.  Then you can reference that artifact just like you
> would any other artifact.  The difference is that Maven knows to find it
> inside the reactor during the build.


I'm already doing this as well [2]; thanks anyway though.

It is far better to bend your expectations to the way that Maven wants
> to work than to try to force it into submitting to the way YOU want to
> do things.  Just learn new habits and you will be far happier letting
> Maven do all the neat things it does for you for free.


I'm very willing to restructure the project (i.e. move actual locations of
source files around). However, I don't see any advantage if Maven won't do
things differently. Will it actually build the jar for one project when I
type mvn compile? I am specifying one project as the dependency of another
using the standard group-artifact-version tags [3].

Maven is already correctly building (mvn compile) myproj-plugin before
myproj-base. However, it isn't packaging it as a jar for the Maven Scala
plugin.

Thanks so much,
Nicholas

[1]
http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/pom.xml#L43
[2]
http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/skalch-base/pom.xml#L52
[3]
http://github.com/gatoatigrado/skalch/blob/9e1d2d0fd05c3fd9c7fbbfadfbe44b1bfa31b388/skalch-base/pom.xml#L34

Re: help with multi-module build

Posted by "David C. Hicks" <dh...@i-hicks.org>.
It's hard to say from your description, but it sounds like you need to
do some serious restructuring of your project.  Here's what I think you
need to have:

base-of-project/
    pom.xml

    myproj-plugin/
        pom.xml
        src/main/scala code goes here

    myproj-base/
        pom.xml
        src/main/other code goes here

The pom.xml in the base directory would have your <modules> section and
look like this:

    <modules>
        <module>myproj-plugin</module>
        <module>myproj-base</module>
    </modules>

This is where the pom.xml files in each sub-directory come into play. 
The pom.xml in myproj-base would list "myproj-plugin" as a dependency. 
You assign the groupId, artifactId, and version to myproj-plugin in the
top of its pom.xml.  Then you can reference that artifact just like you
would any other artifact.  The difference is that Maven knows to find it
inside the reactor during the build.

It is far better to bend your expectations to the way that Maven wants
to work than to try to force it into submitting to the way YOU want to
do things.  Just learn new habits and you will be far happier letting
Maven do all the neat things it does for you for free.


Nicholas Tung wrote:
> Hi all,
>
>    I'm having trouble getting a multi-module project to build. What I want
> to do is simple: build a Scala compiler plugin (jar), and then compile the
> rest of the project using that.
>
>    Right now, I have two proxy modules (building things in ../src),
> "myproj-plugin" and "myproj-base". The first builds only the plugin, using
> an assembly to build the jar file -- the output looks fine (though the name
> is a bit long, and I'm not sure how to properly address it). However, when
> "myproj-base" builds, I get "unable to find resource <plugin resource>" [1],
> and it tries downloading "myproj-plugin" from the Scala and Maven
> repositories (ick). I tried specifying the jar name path with "systemPath",
> but no luck.
>
>     If possible, I'd like it to be able to
>
>    - rebuild all Scala files in "myproj-base" when the plugin changes (to
>    make sure the plugin doesn't break anything).
>    - build the entire project by typing "mvn compile" in the base directory
>    (from scratch).
>
>     The full project source is at [2].
>
> Thanks in advance,
> Nicholas
>
> Sorry if this is a duplicate; I have gmail configured to send as
> ntung@ntungbut was subscribed as gatoatigrado@gmail
>
>
>
>
> [1]
>
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] wrap: org.apache.maven.artifact.resolver.ArtifactNotFoundException:
> Unable to download the artifact from any repository
>
> Try downloading the file manually from the project website.
>
> Then, install it using the command:
>
> [2]
> http://github.com/gatoatigrado/skalch/commit/cb258d39c0dc796de8f6c1076e05505bb21f854a
>
>   

help with multi-module build

Posted by Nicholas Tung <ga...@gmail.com>.
Hi all,

   I'm having trouble getting a multi-module project to build. What I want
to do is simple: build a Scala compiler plugin (jar), and then compile the
rest of the project using that.

   Right now, I have two proxy modules (building things in ../src),
"myproj-plugin" and "myproj-base". The first builds only the plugin, using
an assembly to build the jar file -- the output looks fine (though the name
is a bit long, and I'm not sure how to properly address it). However, when
"myproj-base" builds, I get "unable to find resource <plugin resource>" [1],
and it tries downloading "myproj-plugin" from the Scala and Maven
repositories (ick). I tried specifying the jar name path with "systemPath",
but no luck.

    If possible, I'd like it to be able to

   - rebuild all Scala files in "myproj-base" when the plugin changes (to
   make sure the plugin doesn't break anything).
   - build the entire project by typing "mvn compile" in the base directory
   (from scratch).

    The full project source is at [2].

Thanks in advance,
Nicholas

Sorry if this is a duplicate; I have gmail configured to send as
ntung@ntungbut was subscribed as gatoatigrado@gmail




[1]

[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] wrap: org.apache.maven.artifact.resolver.ArtifactNotFoundException:
Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command:

[2]
http://github.com/gatoatigrado/skalch/commit/cb258d39c0dc796de8f6c1076e05505bb21f854a