Ant to Gradle,javaCompile 任务有问题
Ant to Gradle, Problem with javaCompile task
我有以下蚂蚁任务:
<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 上声明的任何依赖项。
还尝试添加对我的 dependencies{} 标签的依赖,但它仍然不起作用。
到处找也找不到解决方法
提前致谢!
我最终这样做了:
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 插件完成此操作,但我需要做的不仅仅是编译,所以坚持执行 java 编译任务。
我有以下蚂蚁任务:
<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 上声明的任何依赖项。 还尝试添加对我的 dependencies{} 标签的依赖,但它仍然不起作用。 到处找也找不到解决方法
提前致谢!
我最终这样做了:
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 插件完成此操作,但我需要做的不仅仅是编译,所以坚持执行 java 编译任务。