I'll follow up on this with a method which worked for me (although still
not the best solution:

The basis for this is a particular project with a src tree in the
following fashion:

/src
     /org....foo.java
     /org.....others.java
/src15  
     /org.....foo.java


Depending on the jdk being used, the appropriate foo.java will be
included in the compilation
Using profiles, I am able to force two separate compilation stages, one
which happens in all cases, the other which only transpires when jdk15
is used.  This was achieved in a similar fashion as show below with one
caveat.

The only issue here is that compiler plugin does not allow the source or
output directories to be configured on the fly.  In my particular case,
when building with a 1.5 jdk I need to change the source and output
directories. To workaround this I had to make a copy of the compiler
plugin and change these fields to be configurable.   

http://jira.codehaus.org/browse/MCOMPILER-13  

POM SNIPPET:



Ruel Loehr
JBoss QA
 

-----Original Message-----
From: Ruel Loehr [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 10, 2006 12:06 PM
To: Maven Users List
Subject: [M2] profiles use case: compilation based off of jdk version

I have a use case which I am trying to flesh out, but so far I can 
Only come up with "kludgy" solutions.   Perhaps someone else has a
better idea of how to accomplish this.

For a particular project I wish to build it differently based upon the
jdk version which is used.

Use Case:

Java14:   
  1)  Compile all source in default source folder and output to
targets/classes.  The source and target options should be set to "1.4".

Java15:
  1)  Compile all source in default source folder and output to
targets/classes.  The source and target options should be set to "1.4".
  2)  Compile all source in /java15 source folder and output to
targets/classes15.   The source and target options should be set to
"1.5".

>From my standpoint, two compilations need to take place.  The first
(java14) would take place in the standard fashion, as it always need to
happen.  The second (java15) would be housed with a jdk15 activated
profile.   Experimentation shows that by defining the compiler plugin
(snippet below) within a profile will not kick it off (if compilation
has already occurred.


Are there any ideas on how this might be achieved?


<build>
</build>
<profiles>
      <profile>
         <id>jdk15</id>
         <!-- this profile should be activated when jdk15 is being used
-->
         <activation>
            <jdk>1.5</jdk>
         </activation>
         <!-- describe what happens when this profile is executed -->
         <build>
            <plugins>
                <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                    
                </configuration>
             </plugin>             
      </plugins>
   </build>      
               
      </profile>
   </profiles>


Ruel Loehr
JBoss QA
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to