我有以下蚂蚁任务:
<javac
srcdir="${mypackage.code.src.java}"
source="1.8"
target="1.8"
destdir="${mypackage.build.output.}"
deprecation="on"
debug="true"
>
<classpath path="${jboss.common.lib.}/hibernate-annotations-3.5.0-Final.jar" />
<classpath path="${jboss.common.lib.}/jboss-ejb3-common.jar" />
<classpath path="${jboss.common.lib.}/scheduler-plugin.jar" />
<classpath path="${jboss.common.lib.}/servlet-api.jar" />
<classpath>
<path>
<fileset dir="${myotherpackage.lib.thirdparty.}">
<include name="jboss-5.1.0.GA/ejb3-persistence.jar" />
<include name="jboss-5.1.0.GA/hibernate-core-4.2.1.final.jar"/>
<include name="jboss-5.1.0.GA/jboss-javaee.jar" />
<include name="jboss-5.1.0.GA/jboss-j2se.jar"/>
<include name="jboss-5.1.0.GA/jsp-api.jar"/>
</fileset>
<fileset dir="${jboss.server.myotherpackage.lib.}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${jboss.server.myotherpackageear.}" >
<include name="**/*.jar"/>
</fileset>
<fileset dir="${mypackage.code.src.www}/WEB-INF/lib" >
<include name="**/*.*" />
</fileset>
</path>
</classpath>
</javac>
我正在尝试将其转换为gradle,到目前为止,我有以下任务:
task doCompile(type: JavaCompile) {
classpath = sourceSets.mySourceSet.output
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
destinationDir = file("$mypackage_build_output")
source = file("$mypackage_code_src_java")
}
也将我的源集定义如下:
sourceSets {
jt3SourceSet {
java {
compileClasspath += files("${jboss_common_lib}/hibernate-annotations-3.5.0-Final.jar")
compileClasspath += files("${jboss_common_lib}/jboss-ejb3-common.jar")
compileClasspath += files("${jboss_common_lib}/scheduler-plugin.jar")
compileClasspath += files("${jboss_common_lib}/servlet-api.jar")
compileClasspath += files("${myotherpackage_lib_thirdparty}/jboss-5.1.0.GA/hibernate-core-4.2.1.final.jar")
compileClasspath += files("${myotherpackage_lib_thirdparty}/jboss-5.1.0.GA/ejb3-persistence.jar")
compileClasspath += files("${myotherpackage_lib_thirdparty}/jboss-5.1.0.GA/jboss-javaee.jar")
compileClasspath += files("${myotherpackage_lib_thirdparty}/jboss-5.1.0.GA/jboss-j2se.jar")
compileClasspath += files("${myotherpackage_lib_thirdparty}/jboss-5.1.0.GA/jsp-api.jar")
compileClasspath += fileTree(dir: "${jboss_common_lib}", include: ['*.jar'])
compileClasspath += fileTree(dir: "${jboss_server_mypackage2ear}", include: ['*.jar'])
compileClasspath += fileTree(dir: "${mypackage_code_src_www}/WEB-INF/lib", include: ['*.*'])
}
}
}
在ant编译中效果很好,但在gradle上它无法识别sourceSet上声明的任何依赖项。还尝试将依赖项添加到我的依赖项{}标签上,但仍然无法正常工作。到处搜索,找不到解决方法
提前感谢!
我最终这样做:
task doCompile(type: JavaCompile) {
classpath = sources //a file collection specifying a list of sources
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
destinationDir = file("$mypackage_build_output")
source = file("$mypackage_code_src_java")
}
还删除了sourceSet,不再需要它。您可以使用java插件完成此操作,但是我需要做的不仅仅是编译,因此请坚持使用javacompile任务。