2011-08-18 3 views
0
I want to define property or want to use maven.plugin.classpath and maven.dependency.classpath in my build.xml. 

How can i do it ? 

Sample code is as below... 

<property> </property> is not working and not able to read the values from my build.xml so please explain me how can i do it ? 


      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.2</version> 
       <executions> 
        <execution> 
         <id>install</id> 
         <phase>install</phase> 
         <goals> 
          <goal>exec</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <property name="plugin_classpath" refid="maven.plugin.classpath" /> 
        <property name="maven_dependency_classpath" refid="maven.dependency.classpath" />    
        <executable>antscript.bat</executable> <!-- ant -f build.xml build --> 
       </configuration> 
      </plugin> 



Hi Sean Patrick Floyd, 


Yes i tried using maven-antrun-plugin but i am not able to setup JDK 1.4.2 version in it. I am trying to specify all possible way to apply JDK version 1.4.2 but it's still taking tools.jar or JDK version, Which maven.bat file is using (jdk 1.5) 

I was using following code in MAVEN-ANTRUN-PLUGIN as below code. 

<plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <version>1.6</version> 

       <executions> 
        <execution> 
         <id>install</id> 
         <phase>install</phase> 
         <goals> 
          <goal>run</goal> 
         </goals> 
         <configuration> 
          <source>${java-version}</source> 
          <target>${java-version}</target> 
          <compilerVersion>${java-version}</compilerVersion> 
          <executable>${java.1.4.2.home}/bin/javac</executable> 
          <target> 

           <property name="plugin_classpath" refid="maven.plugin.classpath" /> 
           <property name="maven_dependency_classpath" refid="maven.dependency.classpath" /> 
           <ant antfile="ant_build.xml" /> 
          </target> 
         </configuration> 
        </execution> 
       </executions> 
       <dependencies> 
        <dependency> 
         <groupId>sun.jdk</groupId> 
         <artifactId>tools</artifactId> 
         <version>1.4.2</version> 
         <scope>system</scope> 
         <systemPath>${java.1.4.2.home}/lib/tools.jar</systemPath> 
        </dependency> 
        <dependency> 
         <groupId>com.sun</groupId> 
         <artifactId>rt</artifactId> 
         <version>${java-version}</version> 
         <scope>system</scope> 
         <systemPath>${java.1.4.2.home}/jre/lib/rt.jar</systemPath> 
        </dependency> 
       </dependencies> 
      </plugin> 



That's why i choose exec GOAL where my SYSTEM JAVA_HOME is 1.4.2 and it's able to execute it if i have all dependencies which i needed. 


Please help me out. 






Thanks. 

Répondre

1

maven.plugin.classpath etc. sont des variables définies dans le maven-antrun-plugin uniquement. Le plugin exec ne connaît pas ces valeurs. En outre, il ne serait pas possible de le faire comme ça en premier lieu, comme vous appelez un fichier .bat externe et donc en commençant un nouveau processus.

Si j'étais vous, j'utiliserais le plugin antrun. Voir the usage page pour plus de détails.


Mise à jour: ok, maintenant je vois votre problème. Non, vous ne pouvez pas utiliser un JDK différent, car antrun fonctionne dans le même VM. Donc, soit vous avez besoin de changer les utilisations de JDK maven, ou vous avez en fait besoin d'utiliser le exec-maven-plugin. Dans ce dernier cas, vous devrez utiliser
dependency:build-classpath -DoutputFile=someFile.txt
et, du côté des fourmis, lire le contenu de someFile.txt comme propriété et créer un chemin de classe à partir de celle-ci. Ou vous pouvez use the %classpath variable placeholder dans vos arguments de ligne de commande.

+0

Salut Sean Patrick Floyd - S'il vous plaît vérifier ma question éditée. – user886614

+0

@ user886614 Serait-il possible d'utiliser le plugin maven-antrun pour invoquer une tâche Ant avec l'environnement Java requis? Vous pouvez utiliser les propriétés maven classpath disponibles dans le plugin antrun pour fournir des emplacements de jar de dépendances à la tâche . –

0

Oui réponse correcte que j'ai trouvé est d'utiliser la version MAVEN qui prend en charge JDK 1.4.2. Donc je dois utiliser apache-maven-2.0.11 qui supporte JDK 1.4.2

Merci à tous pour vos réponses.

Questions connexes