I'd like to use both the Gradle project-report and jacoco plugins in my project. To illustrate the problem I'm having though, I opened build.gradle at: gradle-1.7-rc-1/samples/testing/jacoco/quickstart and modified it to be:
apply plugin: "java"
apply plugin: "jacoco"
apply plugin: "project-report"
running a gradle projectReport then gives me the error:
gradle projR
:dependencyReport
:propertyReport
:taskReport FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':taskReport'.
> Could not determine the dependencies of task ':jacocoTestReport'.
Any advice on how to get these two plugins to play nice together would be appreciated (note, they both work independently of each other).
Thanks
Covered by GRADLE-2917, will be fixed in version 1.10 as described in the Gradle Forum
Related
I have a multi-project build and I'm including the groovy plugin in the master build.gradle like this:
plugins {
id 'groovy'
}
However, one of my subprojects which has groovy sources is doing this:
sourceSets {
main {
java.srcDirs = []
groovy.srcDirs += ["src/main/java", "src/main/groovy"]
}
}
And I get an error:
> Could not get unknown property 'srcDirs' for source set 'groovy' of type org.gradle.api.internal.tasks.DefaultSourceSet.
I'm in the process of upgrading my build scripts to work under gradle v5.5.1 rather than v2.13. This was working previously where I had this in the subproject build file:
apply plugin: 'groovy'
But after upgrading to 5.5.1 from 2.13 it started giving me this:
* What went wrong:
A problem occurred evaluating project ':mysubproj'.
> Failed to apply plugin [class 'org.gradle.api.plugins.GroovyBasePlugin']
> Cannot change attributes of configuration ':mysubproj:apiElements' after it has been resolved
Which is why I thought I should declare the plugin in the master build script.
Shouldn't my plugin reference in the master build script make the subproject aware of the groovy extensions? If not, what's the correct way? Thank you!
The issue is the Groovy plugin isn't being applied to the subproject, you will want to apply it appropriately.
allprojects {
apply plugin: 'groovy'
}
I know in the past the new plugin style didn't work for subprojects, that may have been resolved and if so - use it.
As for the exception, when you seem to be doing the above, I'd need the buildscripts to advise you :)
In a multi-project build using Gradle v5.5.1 I am trying to apply the ear plugin only to certain subprojects (as described in using plugins). You can see here that I'm trying to apply it for subprojects ending in EAR:
subprojects { Project proj ->
afterEvaluate {
if(proj.projectDir.name.endsWith('EAR')){
logger.debug "{} looks like an EAR subproject", proj.name
apply plugin: 'ear'
defaultTasks 'ear'
}
}
However, it applies it to my master project instead (output log):
10:53:36.366 [DEBUG] [org.gradle.api.Project] MAG820PAYMENTRECONEAR looks like an EAR subproject
10:53:36.367 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply plugin org.gradle.ear to root project 'master'' started
Then when it gets to the execution of my subproject it says the ear task is not found:
10:53:36.375 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Task 'ear' not found in project ':MAG820PAYMENTRECON:MAG820PAYMENTRECONEAR'.
I know this works because I have other projects doing similar but I can't figure out why this one is working this way.
What am I doing wrong??
Simply use proj.apply plugin: 'ear' to call the method on the sub-project
I am building a plugin in IntelliJ and Gradle, and have the following question:
What is the difference between the predefined tasks build and buildSearchableOptions in Gradle?
I can see that :buildSearchableOptions is called as part of :build and that it produces its own JAR file.
They come from two different plugins.
Assuming a Java project, the build task comes from the java plugin which in turn comes from the life cycle/base plugin:
https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/java/org/gradle/api/plugins/JavaBasePlugin.java#L74
https://docs.gradle.org/current/userguide/base_plugin.html
The buildSearchableOptions task comes from the org.jetbrains.intellij plugin:
https://github.com/JetBrains/gradle-intellij-plugin/blob/master/src/main/groovy/org/jetbrains/intellij/IntelliJPlugin.groovy#L350..L360
https://github.com/JetBrains/gradle-intellij-plugin#tasks
I have a Java 8 project build using gradle 1.12 which works perfect. Now I want to use FindBugs and as I use Java 8 I have to use FindBugs 3. But the build hangs in findbugsMain:
:my-module:compileJava UP-TO-DATE
:my-module:processResources UP-TO-DATE
:my-module:classes UP-TO-DATE
> Building 6% > :my-module:findbugsMain
The resulting build.gradle contains the following:
apply plugin: 'java'
apply plugin: 'findbugs'
findbugs.toolVersion = '3.0.0'
dependencies {
compile 'com.google.code.findbugs:annotations:3.0.0'
…
}
Any Idea why the build is getting hanged? What should I do?
Ok, after all it seems that findbugs 3 simply does not work with gradle 1.x!
After switching to gradle 2.1 all works fine.
Thanks to Peter Niederwieser!
I am facing the following problem. I need to build the multi-project, but when I try to add the dependency I got the following error.
Root Project's settings.gradle:
include 'DbServices','HelloWeb'
Root Project's build.gradle:
apply plugin: 'java'
project(':HelloWeb') {
dependencies {
compile (':DbServices')
}
}
DbServices's build.gradle:
apply plugin: 'java'
HelloWeb's build.gradle:
apply plugin: 'java'
However, then I am getting the following error when synchronize with the gradle tasks on Root Project:
Executing command: "tasks"
FAILURE: Build failed with an exception.
Where:
Build file 'D:\MyDeployment\RootProject\build.gradle' line: 21
What went wrong:
A problem occurred evaluating root project 'RootProject'.
Could not find method compile() for arguments [:DbServices] on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated#3b3e3b3e.
Try:
Run with --info or --debug option to get more log output.
Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'RootProject'.
The documentation uses the following syntax:
dependencies {
compile project(':DbServices')
}
The notion of compile dependencies is introduced by the java plugin. Therefore, this plugin has to be applied (to the HelloWeb project) before declaring dependencies. The easiest way to fix this is to move the dependencies block into HelloWeb's build.gradle. Additionally, the project dependency syntax needs to be fixed according to JB Nizet's answer.