2016-10-28 138 views
1

我在写一个定制的gradle插件,它生成代码并注入一些新的gradle任务。我的问题是当前gradlew check任务compileReleaseJavaWithJavaccompileDebugJavaWithJavac失败。调试gradle任务compileReleaseJavaWithJavac

在windows上,任务运行正常,在Linux和Mac上任务失败。这可能暗示路径或目录分隔符存在错误。

这里是确切的错误:

:examples:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). 
/the/full/path/to/file/MainActivity.java:10: error: package R does not exist 
     setContentView(R.layout.activity_main); 
         ^
1 error 

我的问题是,现在我该怎么调试特殊任务?我想看看课程路径,因为我猜想出现了问题。

之前说,但嘿R文件不生成:是的。我在文件系统中看到该文件。

当我在Mac上禁用并行任务时,我玩得更多一点,它也编译得很好。然而在特拉维斯它仍然失败。

+0

请将您的travis.yml内容添加到问题或文件的链接中。 – albodelu

+1

@ardock这里是:https://github.com/rekire/PojoBooster/blob/d6b51c81191ecb99017585a28764bb7793da3afe/.travis.yml – rekire

回答

1

更新的响应:

目前我只知道:

  • 这不是一个特拉维斯-CI的问题,因为我地重现它在Linux 机器上。
  • 它与R软件包无关,它是默认软件包,不需要导入。
  • 它与appcompat错误没有关系,任何随机更改都可以成功构建。
  • 似乎与增量构建有关,see this,也this并尝试将其设置为false。在第一次构建

Story: Don't compile a source file when the API of its compile dependencies has not changed

Currently, changing the body of a method invalidates all class files that have been compiled against the method's class. Instead, only the method's class should be recompiled. Similarly, changing a resource file invalidates all class files that included that resource file in the compile classpath. Instead, resource files should be ignored when compiling.

We don't necessarily need a full incremental Java compilation to improve this. For example, the Java compilation task may consider the API of the compile classpath - if it has changed, then compile all source files, and if it has not, skip the task (assuming everything else is up to date). This means that a change to a method body does not propagate through the dependency graph.

Stracktrace错误(第二建立成功):

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':examples:app:compileReleaseJavaWithJavac'. 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 
... 
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details. 
     at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:48) 

也许this warningJava8annotations是相关的。我希望这有助于我离开,因为我做了任何改变,使得构建成功,很难理解真正的问题。

我配置的Java 8使用像this

android { 
    ... 
    defaultConfig { 
    ... 
    jackOptions { 
     enabled true 
    } 
    } 
    compileOptions { 
    sourceCompatibility JavaVersion.VERSION_1_8 
    targetCompatibility JavaVersion.VERSION_1_8 
    } 
} 

上回应:

import your.package.R; 

R:

尝试使用您的真实包添加到您的MainActivity.java下一个进口文件不能正确生成,因为像以前的错误:

COMPILE-Error: package android.support.v7.app does not exist 

我刚测试过它。我在linux机器上下载了你的项目(这不是Travis-ci的问题)。

我的下一行取代了依赖,它的工作原理:

compile "com.android.support:appcompat-v7:25.0.0" 

所以我建议你添加{ }

compile "com.android.support:appcompat-v7:${project.supportLibVersion}" 

真的,我不知道,现在它的工作始终没有建议的更改。

也许,这是真的,它是关于并行选项问题,并在第二次运行,但我们接近。