Issue
I have a Java library that includes a large amount of generated code in the src/gen/java
directory. The code generator isn't very mature, so the generated code triggers tons of Eclipse warnings. While it's relatively easy to suppress these warnings manually, they come back the moment I regenerate the project. I also want to avoid any manual steps when cloning the repository and setting up the project for the first time. How can I instruct Gradle to automatically ignore the compiler warnings in a generated Eclipse project?
Solution
Suppose you have something like this in your build.gradle
already:
apply plugin: "eclipse"
sourceSets {
main {
srcDirs += ["src/gen/java"]
}
}
Add the eclipse
block below:
eclipse {
classpath {
file {
whenMerged {
entries.each { entry ->
if (entry.kind == "src" && entry.path.endsWith("src/gen/java")) {
entry.entryAttributes["ignore_optional_problems"] = "true"
}
}
}
}
}
}
Gradle will generate a .classpath
file with a classpath entry that results in Eclipse ignoring compiler warnings for source in the src/gen/java
directory:
<classpathentry output="bin/main" kind="src" path="src/gen/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value"main,test"/>
<attribute name="ignore_optional_problems" value="true"/>
</attributes>
</classpathentry>
Answered By - jstricker
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.