[英]gradle classes are not generated
I am trying to convert my project to gradle and unable to get the class files generated under build folder.我正在尝试将我的项目转换为 gradle,但无法获取在构建文件夹下生成的 class 文件。 Here is the build.gradle file:这是 build.gradle 文件:
import org.gradle.internal.os.OperatingSystem;
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {
srcDirs = ["abc/def/"]
include('include/Constants.java')
}
}
}
task initial(type: Exec) {
doFirst {
println 'Started compiling constants'
}
if(OperatingSystem.current().isWindows()) {
println 'Compiling on windows'
//Run some bash script here
}
else {
print 'Compiling on unix'
//Run some shell script here
}
doLast {
println 'Finish compiling constants'
}
}
jar {
baseName = 'output'
}
dependencies {
compile files('../lib/log4j/log4j.jar')
compile files('../lib/findbugs/findbugs.jar')
compile files('../lib/guava/guava-19.0.jar')
}
When i do gradle build, it says successfull, but see no classes generated under build folder.当我执行 gradle 构建时,它表示成功,但在构建文件夹下看不到生成的类。 Any help?有什么帮助吗?
Fixed it after some debugging. 经过调试后修复。 The issue was the include after the srcDirs did not work as the path was one level higher than the path defined in srcDirs. 问题是在srcDirs无法正常工作后出现包含问题,因为该路径比srcDirs中定义的路径高一级。
I had a similar issue the other day, it was not generating the compiled classes when I run the build on IntelliJ or even on the terminal.前几天我遇到了类似的问题,当我在 IntelliJ 甚至终端上运行构建时,它没有生成编译的类。
After trying a lot of things what solved the issue was deleting the .gradle
directory and running again a ./gradlew clean build
.在尝试了很多事情之后,解决问题的方法是删除.gradle
目录并再次运行./gradlew clean build
。
It was a weird one, but I hope it might help to someone having the same issue.这是一个奇怪的问题,但我希望它能对遇到同样问题的人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.