You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mariusz Plucinski <pl...@gmail.com> on 2012/04/02 17:46:41 UTC

Using artifacts as resources in other projects.

Hello Maven users,

I am really newbie in Maven, so I am not pretty sure if my way of thinking is right. If it's not, do not hesitate to criticize it.

I am developing medium-size project, which contains both Java SE and Android sub-projects. After many troubles with Ant, I've decided to give Maven's a try.

To make it simple, let's say that I have three projects:
 - Android application
 - Swing application
 - Main application (also uses Swing, but this is not important now)

Those three applications are building pretty well with maven. I am typing "mvn package" and - as expected - I get one *.apk file and two *.jar files. Thanks to maven-shade-plugin, JAR files contains all required dependencies. They are, of course, executable jars.

Goal of Main application is to "generate" Swing and Android applications for user's request. Those applications are prebuilt, so Main program needs only to slightly modify it before putting onto user's disk. However, I would like to deliver only one file - Main.jar. Two other files - Android.apk and Swing.jar should be put as entire files inside of Main.jar (they should stay there as full files, without unpacking or anything). This way, when user decided to generate e.g. Swing application, Main application gets whole file Swing.jar from itself, modifies it a little and put somewhere to user's file system. That same is possible in case of generating Android program. But it requires shipping Android.apk and Swing.jar inside of Main.jar.

Is it possible to be done using Maven? I suppose that Swing.jar and Android.apk should be provided as resources during build of Main.jar, but I don't know how to instruct Maven to do it this way. I have tried to set <phase>compile</phase> in maven-jar-plugin configuration in Swing.jar. I suppose it is wrong solution - in compile phase, Main application should already have all required resources. Is there any way to instruct Maven to "package" my Android and Swing projects during "prepare-resources" of Main project? Of course, those two are dependencies, so Main project should be informed, that resources were changed in case of modifications in those two.

I am using Maven 3.0.3 and m2e 1.0.200.

Thank you in advance for any help/advise/criticism :).

Best Regards,
Mariusz Pluciński



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


Re: Using artifacts as resources in other projects.

Posted by Wayne Fay <wa...@gmail.com>.
> However, I would like to deliver only one file - Main.jar. Two other files - Android.apk
> and Swing.jar should be put as entire files inside of Main.jar (they should stay there
> as full files, without unpacking or anything). This way, when user decided to generate
> e.g. Swing application, Main application gets whole file Swing.jar from itself, modifies
> it a little and put somewhere to user's file system. That same is possible in case of
> generating Android program. But it requires shipping Android.apk and Swing.jar inside
> of Main.jar.

I don't see this as being a good way to handle your user case.

Instead I think you should be using the assembly plugin to create a
Zip file containing your 3 files, then provide instructions to your
users about how to unzip and run the Main.jar and tell Main.jar to
look in the same directory (or under a lib/ subdir) it is located in
for the other 2 files.

Wayne

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


Re: Using artifacts as resources in other projects.

Posted by Mariusz Plucinski <pl...@gmail.com>.
Wiadomość napisana przez Jeff MAURY w dniu 2 kwi 2012, o godz. 21:02:

> You should probably use the maven assembly plugin

Thanks. I'll look on this plugin when come back to that project.

Best regards,
Mariusz Pluciński





Re: Using artifacts as resources in other projects.

Posted by Jeff MAURY <je...@jeffmaury.com>.
You should probably use the maven assembly plugin

Jeff
Le 2 avr. 2012 17:47, "Mariusz Plucinski" <pl...@gmail.com> a
écrit :

> Hello Maven users,
>
> I am really newbie in Maven, so I am not pretty sure if my way of thinking
> is right. If it's not, do not hesitate to criticize it.
>
> I am developing medium-size project, which contains both Java SE and
> Android sub-projects. After many troubles with Ant, I've decided to give
> Maven's a try.
>
> To make it simple, let's say that I have three projects:
>  - Android application
>  - Swing application
>  - Main application (also uses Swing, but this is not important now)
>
> Those three applications are building pretty well with maven. I am typing
> "mvn package" and - as expected - I get one *.apk file and two *.jar files.
> Thanks to maven-shade-plugin, JAR files contains all required dependencies.
> They are, of course, executable jars.
>
> Goal of Main application is to "generate" Swing and Android applications
> for user's request. Those applications are prebuilt, so Main program needs
> only to slightly modify it before putting onto user's disk. However, I
> would like to deliver only one file - Main.jar. Two other files -
> Android.apk and Swing.jar should be put as entire files inside of Main.jar
> (they should stay there as full files, without unpacking or anything). This
> way, when user decided to generate e.g. Swing application, Main application
> gets whole file Swing.jar from itself, modifies it a little and put
> somewhere to user's file system. That same is possible in case of
> generating Android program. But it requires shipping Android.apk and
> Swing.jar inside of Main.jar.
>
> Is it possible to be done using Maven? I suppose that Swing.jar and
> Android.apk should be provided as resources during build of Main.jar, but I
> don't know how to instruct Maven to do it this way. I have tried to set
> <phase>compile</phase> in maven-jar-plugin configuration in Swing.jar. I
> suppose it is wrong solution - in compile phase, Main application should
> already have all required resources. Is there any way to instruct Maven to
> "package" my Android and Swing projects during "prepare-resources" of Main
> project? Of course, those two are dependencies, so Main project should be
> informed, that resources were changed in case of modifications in those two.
>
> I am using Maven 3.0.3 and m2e 1.0.200.
>
> Thank you in advance for any help/advise/criticism :).
>
> Best Regards,
> Mariusz Pluciński
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>