简体   繁体   English

gradle 类未生成

[英]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.

相关问题 使用IntelliJ中的Gradle导入Protobuf生成的类 - Import Protobuf generated classes using Gradle in IntelliJ 使用gradle时找不到Protobuf生成的类 - Protobuf generated classes cannot be found when using gradle 如何在 Gradle Javadoc 任务中提供生成的数据绑定类? - How to provide generated data-binding classes in a Gradle Javadoc task? 在Gradle中进行编译之前,如何移动生成的查询类型类? - How to move generated query type classes before compiling in Gradle? 由IntelliJ在另一个模块中看不到由gradle生成的ProtoBuffer类 - ProtoBuffer generated classes by gradle are not visible in another module by IntelliJ Dagger2 + gradle + intellij:找不到生成的类并将其视为编译错误/不会自动完成 - Dagger2 + gradle + intellij: generated classes are not found and treated as a compile error/won't autocomplete 无法通过 IntelliJ Idea 和 Gradle 使用构建文件夹中生成的类 - Can't use generated classes from build folder with IntelliJ Idea and Gradle OpenAPI 生成的类并为生成的类应用 JsonView - OpenAPI generated classes and applying JsonView for the generated classes Gradle无法识别班级 - Gradle not recognizing classes 在gradle中排除声纳类 - Exclude sonar classes in gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM