Could not determine the dependencies of task ':xxx:check' - java

I have a project using Gradle 1.12, it goes well using gradle assemble, but exception occurs when executing gradle build as follows:
* What went wrong:
Could not determine the dependencies of task ':JavaUtil:check'.
> groovy.lang.MissingMethodException: No signature of method: org.gradle.api.internal.file.DefaultSourceDirectorySet.getTaskName() is applicable for
rgument types: (java.lang.String, null) values: [findbugs, null]
Possible solutions: getName()
Having the dependencies settings in gradle script of JavaUtil's parent folder like this:
dependencies {
compile (project (':JavaUtil')) {transitive = false}
The same error occurs when I executed gradle build in JavaUtil folder.
Any ideas what happens here?

Related

Error compiling class that contains trait in groovy

I have a module which uses Groovy (2.5.14) and Scala (2.11.6). All the dependencies are maintained by gradle (ver 6.x). While building the project I am getting some strange compilation Error as shown below:
[Error] Class A.B.C$Trait$FieldHelper not found - continuing with a stub.
(where C is some trait)
To be precise, while build the module, the task compileTestScala fails with the above error.
Here is the snapshot of the build gradle
compileTestScala {
classpath = classpath.plus(files(compileTestGroovy.destinationDir))
dependsOn compileTestGroovy
}
compileScala {
classpath = classpath.plus(files(compileGroovy.destinationDir))
dependsOn compileGroovy
}
However, the compileScala builds successfully. What could be the root cause?

My project, which uses a gradle dependency, stopped working when I restarted my computer

I am making a program that requires a Gradle dependency, and I am using eclipse. It was working yesterday, and I didn't change anything, but when I restarted my computer it stopped working. This is my first time using Gradle.
I tried refreshing Gradle and restarting eclipse, but it still doesn't see the dependency. I tried changing the distribution url of Gradle in the gradle-wrapper.properties file, and copying everything from one project to another but nothing has worked so far.
this is the content of my build.gradle file
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
apply plugin: "eclipse"
}
repositories {
maven {
url "https://dl.bintray.com/emilybjoerk/lisoft"
}
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// this is the dependency I am trying to get to work.
compile 'org.li-soft.gonector:gonector:1.0.0'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:27.0.1-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
This is the error message:
Could not run phased build action using Gradle distribution
'https://services.gradle.org/distributions/gradle-5.6.1-bin.zip'. A
problem occurred configuring root project 'MyGoEngine'. Could not open
cp_proj remapped class cache for ass53uh6ku2mc5yoyd4qs6g8f
(C:\Users\Nikolas.gradle\caches\5.6.1\scripts-remapped\build_159eps3wjadzhd5aqrvmhdzni\ass53uh6ku2mc5yoyd4qs6g8f\cp_proje7ca86eb00f9d6cbee2b842ef043afcb).
Could not open cp_proj generic class cache for build file
'C:\Users\Nikolas\eclipse-workspace\MyGoEngine\build.gradle'
(C:\Users\Nikolas.gradle\caches\5.6.1\scripts\ass53uh6ku2mc5yoyd4qs6g8f\cp_proj\cp_proje7ca86eb00f9d6cbee2b842ef043afcb).
BUG! exception in phase 'conversion' in source unit 'BuildScript'
org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to
org.codehaus.groovy.ast.expr.ArgumentListExpression
org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to
org.codehaus.groovy.ast.expr.ArgumentListExpression
I deleted the contents of C:\Users\Nikolas.gradle\caches, and ran again. This was the console error:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'MyGoEngine'.
Could not open cp_proj remapped class cache for j3obw14yy0cihl9fkn41unq7
(C:\Users\Nikolas.gradle\caches\5.6.1\scripts-remapped\build_159eps3wjadzhd5aqrvmhdzni\j3obw14yy0cihl9fkn41unq7\cp_proje7ca86eb00f9d6cbee2b842ef043afcb).
Could not open cp_proj generic class cache for build file 'C:\Users\Nikolas\eclipse-workspace\MyGoEngine\build.gradle'
(C:\Users\Nikolas.gradle\caches\5.6.1\scripts\j3obw14yy0cihl9fkn41unq7\cp_proj\cp_proje7ca86eb00f9d6cbee2b842ef043afcb).
BUG! exception in phase 'conversion' in source unit 'BuildScript' org.codehaus.groovy.ast.expr.TupleExpression cannot be
cast to org.codehaus.groovy.ast.expr.ArgumentListExpression
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s

Gradle compileJava Task keeps failing

alright i've been hiting my head against the wall for quite sometime now, and now i dont even know what to search for to find a solution, here are my files
build.gradle
//Applying the Gradle BND Plugin for Workspace Builds
//https://github.com/bndtools/bnd/blob/master/biz.aQute.bnd.gradle/README.md
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:${bnd_version}"
}
}
apply plugin: 'biz.aQute.bnd.workspace'
apply plugin: 'java'
// Repositorios, aguante Maven Central.
repositories {
mavenCentral()
/* Excluded, uso la dependecia de otro lado ahora.
flatDir {
dirs '/home/feddericokz/devTools/Equinox/Equinox-Oxygen-1a/plugins'
}
*/
}
// Dependencias
dependencies {
// https://mvnrepository.com/artifact/org.osgi/org.osgi.core
compile group: 'org.osgi', name: 'org.osgi.core', version: '6.0.0'
}
settings.gradle
/*
* This settings file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
* In a single project build this file can be empty or even removed.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.3.1/userguide/multi_project_builds.html
*/
/*
// To declare projects as part of a multi-project build use the 'include' method
include 'shared'
include 'api'
include 'services:webservice'
*/
rootProject.name = 'bndWorkspace'
include 'com.feddericokz.helloworld'
when trying to run gradle jar from the command line, i get an error as it the compiler cant find the osgi dependencies to compile the classes
Task :com.feddericokz.helloworld:compileJava FAILED
/home/feddericokz/testingDir/bndWorkspace/com.feddericokz.helloworld/src/com/feddericokz/helloworld/HelloWorldActivator.java:3: error: package org.osgi.framework does not exist
import org.osgi.framework.BundleActivator;
^
/home/feddericokz/testingDir/bndWorkspace/com.feddericokz.helloworld/src/com/feddericokz/helloworld/HelloWorldActivator.java:4: error: package org.osgi.framework does not exist
import org.osgi.framework.BundleContext;
^
/home/feddericokz/testingDir/bndWorkspace/com.feddericokz.helloworld/src/com/feddericokz/helloworld/HelloWorldActivator.java:6: error: cannot find symbol
public class HelloWorldActivator implements BundleActivator {
^
symbol: class BundleActivator
/home/feddericokz/testingDir/bndWorkspace/com.feddericokz.helloworld/src/com/feddericokz/helloworld/HelloWorldActivator.java:8: error: cannot find symbol
public void start(BundleContext bundleContext) throws Exception {
^
symbol: class BundleContext
location: class HelloWorldActivator
/home/feddericokz/testingDir/bndWorkspace/com.feddericokz.helloworld/src/com/feddericokz/helloworld/HelloWorldActivator.java:13: error: cannot find symbol
public void stop(BundleContext bundleContext) throws Exception {
^
symbol: class BundleContext
location: class HelloWorldActivator
/home/feddericokz/testingDir/bndWorkspace/com.feddericokz.helloworld/src/com/feddericokz/helloworld/HelloWorldActivator.java:7: error: method does not override or implement a method from a supertype
#Override
^
/home/feddericokz/testingDir/bndWorkspace/com.feddericokz.helloworld/src/com/feddericokz/helloworld/HelloWorldActivator.java:12: error: method does not override or implement a method from a supertype
#Override
^
7 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':com.feddericokz.helloworld:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
2 actionable tasks: 1 executed, 1 up-to-date
What am i doing wrong?
EDIT: a typo
If you are using a Bnd workspace model build, then you must configure the build path through each project's bnd.bnd file using the -buildpath Bnd instruction. Then the Bnd gradle plugin will use that information to program the configurations for java compilation.
Your example shows setting a compile dependency for the root gradle project which is wrong since (1) you should be using -buildpath in the project's bnd.bnd file and (2) it is done in the root project which is not meaningful to any child projects like your com.feddericokz.helloworld project.
So change your build.gradle file to not apply the 'java' plugin to the root project and not set compile dependencies for the root project and change your Bnd workspace so that the workspace (cnf) has configured repositories to access the desired bundles, for example https://github.com/osgi/enroute.workspace/blob/4070ff6668a1ee79b9b01cfa4caab86869247e7b/cnf/ext/enroute.bnd#L22-L28, and then set each project's bnd.bnd file to have the desired bundles on the -buildpath.
It is unclear if bnd_version is defined in this line:
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:${bnd_version}"
Consider adding a gradle.properties file with:
bnd_version=3.5.0
(or whatever version is apporpriate). As best as I can reproduce your situation, my example works for me with this.

Failed to apply plugin [class 'org.gradle.api.plugins.scala.ScalaBasePlugin']: Gradle v2.13

Trying to build my project with gradle 2.13.
Getting Error:
MUSGM186035-835:c gm$ gradle build
Version suffix : -6
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/gm/IdeaProjects/repo/a/b/c/build.gradle' line: 2
* What went wrong:
A problem occurred evaluating project ':b:c:QGInitiator'.
> Failed to apply plugin [class 'org.gradle.api.plugins.scala.ScalaBasePlugin']
> A dependency must not be empty
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
BUILD FAILED
Total time: 8.397 secs
My build.gradle file looks like,
apply plugin: 'java'
apply plugin:'scala'//Line with error
ourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile "org.scala-lang:scala-library:2.11.1"
}
This project is part of another project which has other gradle files. But I am not buling the parent project. Not sure what is happening with my dependency.
Stacktrace:
Caused by: org.gradle.api.InvalidUserDataException: A dependency must not be empty
at org.gradle.api.internal.tasks.DefaultTaskDependency.addValue(DefaultTaskDependency.java:122)
at org.gradle.api.internal.tasks.DefaultTaskDependency.add(DefaultTaskDependency.java:115)
at org.gradle.api.internal.AbstractTask$11.run(AbstractTask.java:323)
at org.gradle.api.internal.tasks.TaskMutator.mutate(TaskMutator.java:37)
at org.gradle.api.internal.AbstractTask.dependsOn(AbstractTask.java:321)
at org.gradle.plugins.ide.idea.IdeaPlugin$_configureForScalaPlugin_closure8.doCall(IdeaPlugin.groovy:229)
at org.gradle.plugins.ide.idea.IdeaPlugin$_configureForScalaPlugin_closure8.call(IdeaPlugin.groovy)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:205)
at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:165)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:159)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:142)
Try applying the idea plugin to the root plugin. I'm not exactly sure what's going on, but that should solve the issue.

Not able to run git submodule init with gradle war plugin

My build.gradle looks like:
apply plugin: 'war'
war {
...
}
I build using gradle war
In the configuration phase, I want to run git submodule update --init --recursive
so I changed my build.gradle to:
apply plugin: 'war'
task configured(type: Exec) {
commandLine "git submodule update --init --recursive"
}
war {
...
}
when I do gradle war:
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':war'.
I do not see my submodules being updated. What is wrong?
EDIT:
I put following line in settings.gradle
exec {
commandLine "git", "submodule", "update", "--init", "--recursive"
}
I removed task configured from build.gradle.
Do you thing thats a good solution??
In the configuration phase, I want to run git submodule update --init --recursive
Your current build is doing this in the execution phase. Why do you want to do it in the configuration phase? Note that this will slow down every single invocation of Gradle.
I do not see my submodules being updated. What is wrong?
Only tasks specified on the command line and their task dependencies will be run. If you don't specify configured on the command line, nor make (say) war depend on it, it won't be run.
What went wrong: Could not determine the dependencies of task ':war'.
Apparently there is some problem in the remainder of your build script (which you didn't show). Perhaps you were trying to do something like war.dependsOn(configured), and didn't get it quite right.

Categories