【问题标题】:Why is class file not generated in JavaCompile task in gradle为什么在gradle的JavaCompile任务中没有生成类文件
【发布时间】:2014-12-31 01:32:45
【问题描述】:

我在使用 gradle 构建我的 android 项目时遇到了一个问题。在我的构建过程中,我需要将单个java文件编译为类文件。我的项目文件结构是app-> build_tools->A.java。我编译 A.java 的任务如下:

 task compileEncodeUtil(type:JavaCompile) {
   println('****************************compileEncodeUtil start*******************')
   source = ['build_tools']
   include '*.java'
   classpath = files('.')
   destinationDir=['build_tools']

 }

当我运行这个任务时,它运行成功,但是在 build_tools 文件夹中,没有类文件。任何帮助将不胜感激。

【问题讨论】:

    标签: java android build compilation gradle


    【解决方案1】:

    对于以下文件夹结构:

    • build.gradle
    • 构建工具/
      • Lo​​l.java
      • 包装/
        • Lo​​l2.java

    以下脚本运行良好:

    apply plugin: 'java'
    
    task compileEncodeUtil(type:JavaCompile) {
       source = ['build_tools']
       include '**/*.java'
       classpath = files('.')
       destinationDir=['build_tools']
    }
    

    【讨论】:

      猜你喜欢
      • 2017-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-12
      • 1970-01-01
      • 1970-01-01
      • 2014-06-04
      相关资源
      最近更新 更多