You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kevin Kingsbury <kk...@austin.rr.com> on 2008/08/18 05:28:45 UTC

Building same source with 1.4 and 1.5 jdks

I am fairly new to using maven. Our project is looking at moving to maven to replace our current ant builds.  

One thing that we are doing in our build is building the same source with the 1.4 and 1.5 jdks.  Basically, we build the modules source with the 1.5 jdk and package it in a module.jar artifact.  Then the build will use the 1.4 jdk to build the same source.  This is packaged in a module-14.jar artifact. 

I have read about how to specify using a different jdk for compiling, but I am not quite sure how to do something like the above.  Is it possible to do this from a single pom file project?  Or do I need to split this up into multiple poms and multiple modules?  There is probably something easy I am missing here, but I just cannot figure it out. 

Thanks
Kevin
Sent via BlackBerry by AT&T

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


Re: Building same source with 1.4 and 1.5 jdks

Posted by Kevin Kingsbury <km...@gmail.com>.
Thanks for the response.

I went ahead and implemented the second option while I was waiting to
hear back on this. It works like a champ.

Thanks again

Kevin



On 8/20/08, Jörg Schaible <jo...@gmx.de> wrote:
> Hi Kevin,
>
> Kevin Kingsbury wrote:
>
>> Thanks Jorg for the pointer to using multiple executions of the compiler.
>> I tried setting that up
>> and I see it try to run, but the it says the classes are already up to
>> date.  I am assuming that this
>> is because it is still looking at the same outputDirectory.
>>
>> How would I configure a different output directory for the execution that
>> I
>> created?  I dont see any
>> compiler options that will allow this and setting the <outputDirectory>
>> option seems to happen at the
>> project level.  So it does not appear possible to set a second output
>> directory that I could then
>> jar up.  Searching in the forums seem to indicate setting a second output
>> directory is not possible
>> either.
>>
>> Any suggestions?
>
> It seems you're right. We use multiple executions but we're bundling all
> classes in the end in one jar (only the JDK 5 specific code is compiled
> with target JDK 5). I silently assumed, that it is possible to set
> different output paths. Setting it using the compiler options directly will
> not help, since Maven will have a look at the wrong directory to decide
> which classes have to be compiled.
>
> Then all I can propose is my second alternative:
>
>>> An alternative is to use a separate project for the 1.4 version. Simply
>>> create an attached source jar when creating the 1.5 version and extract
>>> and compile this sources in the 1.4 project.
>
> - Jörg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

-- 
Sent from Gmail for mobile | mobile.google.com

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


Re: Building same source with 1.4 and 1.5 jdks

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Kevin,

Kevin Kingsbury wrote:

> Thanks Jorg for the pointer to using multiple executions of the compiler. 
> I tried setting that up
> and I see it try to run, but the it says the classes are already up to
> date.  I am assuming that this
> is because it is still looking at the same outputDirectory.
> 
> How would I configure a different output directory for the execution that
> I
> created?  I dont see any
> compiler options that will allow this and setting the <outputDirectory>
> option seems to happen at the
> project level.  So it does not appear possible to set a second output
> directory that I could then
> jar up.  Searching in the forums seem to indicate setting a second output
> directory is not possible
> either.
> 
> Any suggestions?

It seems you're right. We use multiple executions but we're bundling all
classes in the end in one jar (only the JDK 5 specific code is compiled
with target JDK 5). I silently assumed, that it is possible to set
different output paths. Setting it using the compiler options directly will
not help, since Maven will have a look at the wrong directory to decide
which classes have to be compiled.

Then all I can propose is my second alternative:

>> An alternative is to use a separate project for the 1.4 version. Simply
>> create an attached source jar when creating the 1.5 version and extract
>> and compile this sources in the 1.4 project.

- Jörg



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


Re: Building same source with 1.4 and 1.5 jdks

Posted by Kevin Kingsbury <km...@gmail.com>.
Thanks Jorg for the pointer to using multiple executions of the compiler.  I
tried setting that up
and I see it try to run, but the it says the classes are already up to
date.  I am assuming that this
is because it is still looking at the same outputDirectory.

How would I configure a different output directory for the execution that I
created?  I dont see any
compiler options that will allow this and setting the <outputDirectory>
option seems to happen at the
project level.  So it does not appear possible to set a second output
directory that I could then
jar up.  Searching in the forums seem to indicate setting a second output
directory is not possible
either.

Any suggestions?

Thanks,
Kevin


On Mon, Aug 18, 2008 at 4:33 PM, Jörg Schaible <jo...@gmx.de>wrote:

> Hi Kevin,
>
> Kevin Kingsbury wrote:
>
> > Thanks for the reply Tobias.
> >
> > I will look at build profiles more and see if that will help.
> >
> > One additional question though.  Is there any way to run both profiles
> > using a single maven command.  What I was hoping to accomplish is to
> > run the 1.5 compile and then after that the 1.4 compile so both
> > versions of jar are created once the maven command has finished.  The
> > way I understand it now, I would need to call the two build profiles
> > separately.
>
> In this case you do not use profiles, but configure for the compiler and
> jar
> plugin a second execution. The configuration for the second execution of
> the compiler plugin must use a different target directory and the second
> execution of the jar plugin must create an archive for that directory.
>
> An alternative is to use a separate project for the 1.4 version. Simply
> create an attached source jar when creating the 1.5 version and extract and
> compile this sources in the 1.4 project.
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Building same source with 1.4 and 1.5 jdks

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Kevin,

Kevin Kingsbury wrote:

> Thanks for the reply Tobias.
> 
> I will look at build profiles more and see if that will help.
> 
> One additional question though.  Is there any way to run both profiles
> using a single maven command.  What I was hoping to accomplish is to
> run the 1.5 compile and then after that the 1.4 compile so both
> versions of jar are created once the maven command has finished.  The
> way I understand it now, I would need to call the two build profiles
> separately.

In this case you do not use profiles, but configure for the compiler and jar
plugin a second execution. The configuration for the second execution of
the compiler plugin must use a different target directory and the second
execution of the jar plugin must create an archive for that directory.

An alternative is to use a separate project for the 1.4 version. Simply
create an attached source jar when creating the 1.5 version and extract and
compile this sources in the 1.4 project.

- Jörg


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


Re: Building same source with 1.4 and 1.5 jdks

Posted by Kevin Kingsbury <km...@gmail.com>.
Thanks for the reply Tobias.

I will look at build profiles more and see if that will help.

One additional question though.  Is there any way to run both profiles
using a single maven command.  What I was hoping to accomplish is to
run the 1.5 compile and then after that the 1.4 compile so both
versions of jar are created once the maven command has finished.  The
way I understand it now, I would need to call the two build profiles
separately.

Thanks for all the help.
Kevin



On 8/18/08, tobi <to...@code-sourcery.de> wrote:
> Hi Kevin,
>> I am fairly new to using maven. Our project is looking at moving to maven
>> to replace our current ant builds.
>>
>> One thing that we are doing in our build is building the same source with
>> the 1.4 and 1.5 jdks.  Basically, we build the modules source with the 1.5
>> jdk and package it in a module.jar artifact.  Then the build will use the
>> 1.4 jdk to build the same source.  This is packaged in a module-14.jar
>> artifact.
>>
>> I have read about how to specify using a different jdk for compiling, but
>> I am not quite sure how to do something like the above.  Is it possible to
>> do this from a single pom file project?  Or do I need to split this up
>> into multiple poms and multiple modules?  There is probably something easy
>> I am missing here, but I just cannot figure it out.
>>
> This *should* be possible by having two different profiles in a single
> pom.xml file (one profile configures the maven-compiler plugin to use
> JDK1.5 and the maven-jar-plugin to create an artifact with classifier
> "jdk14" ,  the  other one uses  JDK1.4 and classifier "jdk15"). When
> running maven you could then use the  "-P<profile id>" option to
> activate the corresponding profile.
>
> The bad news: IIRC , I tried to do a similiar thing a few weeks ago and
> got hit by
>
> 1.) http://jira.codehaus.org/browse/MDEPLOY-45 ( don't know if a fixed
> plugin version is already released by now, I think I used either a
> snapshot or compiled and installed the plugin from SVN myself )
> 2.) http://jira.codehaus.org/browse/MINSTALL-41
> 3.) http://jira.codehaus.org/browse/MDEPLOY-78
>
> While I was able to get around bug #1 , I was unable to get around bug
> #2 and #3 (but yeah, I'm lazy ... the issues already have patches
> attached so I guess one could grab the plugins from SVN , apply the
> patches and install them locally).
>
> Maybe I did something wrong (hints anyone?) , I was quite surprised that
> obvious Maven core features did not work.
>
> Regards,
>
> Tobias
>> Thanks
>> Kevin
>> Sent via BlackBerry by AT&T
>>
>> ---------------------------------------------------------------------
>> 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
>
>

-- 
Sent from Gmail for mobile | mobile.google.com

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


Re: Building same source with 1.4 and 1.5 jdks

Posted by tobi <to...@code-sourcery.de>.
Hi Kevin,
> I am fairly new to using maven. Our project is looking at moving to maven to replace our current ant builds.  
>
> One thing that we are doing in our build is building the same source with the 1.4 and 1.5 jdks.  Basically, we build the modules source with the 1.5 jdk and package it in a module.jar artifact.  Then the build will use the 1.4 jdk to build the same source.  This is packaged in a module-14.jar artifact. 
>
> I have read about how to specify using a different jdk for compiling, but I am not quite sure how to do something like the above.  Is it possible to do this from a single pom file project?  Or do I need to split this up into multiple poms and multiple modules?  There is probably something easy I am missing here, but I just cannot figure it out. 
>   
This *should* be possible by having two different profiles in a single 
pom.xml file (one profile configures the maven-compiler plugin to use 
JDK1.5 and the maven-jar-plugin to create an artifact with classifier  
"jdk14" ,  the  other one uses  JDK1.4 and classifier "jdk15"). When 
running maven you could then use the  "-P<profile id>" option to 
activate the corresponding profile.

The bad news: IIRC , I tried to do a similiar thing a few weeks ago and 
got hit by

1.) http://jira.codehaus.org/browse/MDEPLOY-45 ( don't know if a fixed 
plugin version is already released by now, I think I used either a 
snapshot or compiled and installed the plugin from SVN myself )
2.) http://jira.codehaus.org/browse/MINSTALL-41
3.) http://jira.codehaus.org/browse/MDEPLOY-78

While I was able to get around bug #1 , I was unable to get around bug 
#2 and #3 (but yeah, I'm lazy ... the issues already have patches 
attached so I guess one could grab the plugins from SVN , apply the 
patches and install them locally).

Maybe I did something wrong (hints anyone?) , I was quite surprised that 
obvious Maven core features did not work.

Regards,

Tobias
> Thanks
> Kevin
> Sent via BlackBerry by AT&T
>
> ---------------------------------------------------------------------
> 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