exec-maven-plugin 想要将 maven.dependency.classpath 作为我的 EXEC 目标中的变量传递

发布于 2024-11-30 05:47:58 字数 4249 浏览 2 评论 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.
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-12-07 05:47:58

maven.plugin.classpath 等是 maven 中定义的变量仅 -antrun-plugin。 exec 插件不知道这些值。此外,一开始就不可能这样做,因为您正在调用外部 .bat 文件并因此启动一个新进程。

如果我是你,我会使用 antrun 插件。有关详细信息,请参阅使用页面


更新:好的,现在我明白你的问题了。不,你不能使用不同的 JDK,因为 antrun 在同一个虚拟机中工作。因此,要么您需要切换 JDK maven 使用,要么您实际上需要使用 exec-maven-plugin。在后一种情况下,您必须使用
dependency:build-classpath -DoutputFile=someFile。 txt
在 ant 方面,读取 someFile.txt 的内容作为属性并从中创建一个类路径。或者您可以 使用 % classpath 变量占位符 在命令行参数中。

maven.plugin.classpath etc. are variables defined in the maven-antrun-plugin only. The exec plugin doesn't know about these values. Also, it wouldn't be possible to do it like that in the first place, as you are calling an external .bat file and hence starting a new process.

If I were you I'd use the antrun plugin. See the usage page for details.


Update: ok, now I see your problem. No, you can't use a different JDK, since antrun works within the same vm. So either you need to switch the JDK maven uses, or you do in fact need to use the exec-maven-plugin. In the latter case, you will have to use
dependency:build-classpath -DoutputFile=someFile.txt
and on the ant side, read the contents of someFile.txt as a property and create a classpath from it. Or you can use the %classpath variable placeholder in your command line args.

在巴黎塔顶看东京樱花 2024-12-07 05:47:58

是的,我发现正确的答案是使用支持 JDK 1.4.2 的 MAVEN 版本。所以我必须使用支持 JDK 1.4.2 的 apache-maven-2.0.11

谢谢大家的回答。

Yes correct answer which i found is to Use MAVEN version which supports JDK 1.4.2. So i have to use apache-maven-2.0.11 which supports JDK 1.4.2

Thanks all for your answers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文