是否有可能指的是从另一个构建文件在一个构建文件中定义的类路径? [英] Is it possible to refer to a classpath defined in one build file from another build file?

查看:243
本文介绍了是否有可能指的是从另一个构建文件在一个构建文件中定义的类路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在项目中的build文件,有一个<路径> ;

In project A's build file, there is a <path>;

在项目B的编译文件,我想通过执行项目一个工具类&LT; Java的方式&gt; 任务

In project B's build file, I want to execute a tool class in project A by <java> task.

&LT; Java的方式&gt; 任务需要使用该路径在其classpathref的属性。

The <java> task need to use that path in its "classpathref" property.

&LT;路径方式&gt; 项目A的编译文件是相当复杂的,这样我不想把它复制到项目B的编译文件

The <path> in project A's build file is quite complicated so that I don't want to copy it to project B's build file.

那么,这可能是指从另一个构建文件在一个构建文件中定义的类路径?

So is it possible to refer to a classpath defined in one build file from another build file?

推荐答案

使用进口包括的Ant任务是做到这一点的方式....但是,这些都是旨在构建多模块的构建。它通常是一个非常糟糕的主意,夫妻两个不同的项目以这种方式......

Using the import or include ANT tasks is the way to do this.... however, these are both designed build multi-module builds. It's generally a really bad idea to couple two different projects in this manner....

我理解的动机,类路径管理是一个Java构建的最重要和最容易出错的部分之一。我的建议是采用的Apache常春藤并让它管理构建的第三方的依赖。

I understand the motivation, classpath management is one of the most important and error-prone parts of a Java build. My recommendation is to adopt Apache ivy and let it manage your build's 3rd party dependencies.

常春藤 cachepath 任务来创建你的ANT路径,使用依赖声明。

The ivy cachepath task to create your ANT path, using dependency declarations.

   <ivy:cachepath pathid="test.path">
        <dependency org="org.slf4j" name="slf4j-simple" rev="1.6.4" conf="default"/>
        <dependency org="junit" name="junit" rev="4.10" conf="default"/>
    </ivy:cachepath>

本身可以本地存储或检索的罐子 Maven的中央储存库

这篇关于是否有可能指的是从另一个构建文件在一个构建文件中定义的类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆