I've added travis-ci to my github project. Project itself is multi-moduled and consists of :client, :server and :shared.
In the build.gradle of :client module I have organised sourceSets as follows:
sourceSets {
main {
java {
runtimeClasspath += project(":shared").sourceSets.main.java.srcDirs
srcDirs += project(":shared").sourceSets.main.java.srcDirs
}
}
}
Now, when travis-ci runs gradle check it fails with following:
$ gradle server:clean server:check
FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/bduisenov/mockserver/client/build.gradle' line: 55
* What went wrong:
A problem occurred evaluating project ':client'.
> Could not find method main() for arguments [build_ab0sue8nexlysud7wfupu5ddr$_run_closure4_closure12#3fb9a67f] on project ':client'.
* 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: 10.05 secs
The command "gradle server:clean server:check" exited with 1.
Although running locally, I have no issue with it.
Any thoughts on that?
I think that the error simply comes from the gradle version on Travis CI using an old version 2.0. If you generate your gradle wrapper first then Travis CI will use that instead of the built in version - See https://docs.travis-ci.com/user/languages/java#Projects-Using-Gradle. I did try your project locally and there is no problem on Gradle 2.12.
Related
Tring to integrate with JIB (Containerize your Gradle Java project) with my Java project.
Following this documentation: https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin
Added the following to my project:
dependencies {
classpath("gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:3.1.4")
}
apply plugin: 'com.google.cloud.tools.jib'
jib.to.image = 'my-docker-local/my-app'
Gradle version is: 5.6.4
The compilation with "./gradlew" build is working fine. but, when
excecuting "gradle jib" getting the following error:
gradle jib To honour the JVM settings for this build a single-use
Daemon process will be forked. See
https://docs.gradle.org/7.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
FAILURE: Build failed with an exception.
Where: Build file '/Users/igorgumush/dev/java11/my-service/build.gradle' line: 139
What went wrong: A problem occurred evaluating root project 'my-service'.
Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter-web,
build_9nl2gys0kuhc8m4mdlq51u41r$_run_closure4$_closure24#6ea6088b] on
object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 8.0.
Well the solution was very simple.
I used:
./gradlew jib
instead of
grade jib
I am trying to understand Gradle build dependencies but am having trouble using the examples on the Gradle website and wondered if anyone could help.
In the Adding dependencies to a task section of their website there is the following code to be saved in build.gradle:
project('projectA') {
task taskX {
dependsOn ':projectB:taskY'
doLast {
println 'taskX'
}
}
}
project('projectB') {
task taskY {
doLast {
println 'taskY'
}
}
}
They say that the Output of gradle -q taskX is:
> gradle -q taskX
taskY
taskX
But I get:
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/x/build.gradle' line: 3
* What went wrong:
A problem occurred evaluating root project 'x'.
> Project with path ':projectA' could not be found in root project 'x'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
With --stacktrace I get the following:
Caused by: org.gradle.api.UnknownProjectException: Project with path ':projectA' could not be found in root project 'x'.
NOTE: This build.gradle file is the only file in the /tmp/x folder.
------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------
Build time: 2012-12-21 00:00:00 UTC
Revision: none
Groovy: 2.4.15
Ant: Apache Ant(TM) version 1.10.3 compiled on July 19 2018
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Linux 4.15.0-43-generic amd64
This chatper from the documentation explains how to create dependencies between tasks from different (sub)projects of a same build (task Xfrom project projectA depends on task Y from project projectB in the example).
So you need to setup a multi-project build before trying to execute the given example: see basics in multi-project build here
In your case: you need to:
1) create two subproject directories 'projectA' and 'projectB'
2) Create the required settings.gradle file in root project directory, to declare/include the two subprojects
include ("projectA" , "projectB")
In my android studio project, I imported opencsv-3.6.jar as one of module. However, running unit test got the following error:
Error:FAILURE: Build failed with an exception.
What went wrong:
Task 'testClasses' not found in project ':opencsv-3.6'.
Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I tried put the exclude in app/build.gradle but failed.
configurations {
testCompile.exclude module: 'opencsv'
}
In opencsv-3.6/build.gradle, it is:
configurations.create("default")
artifacts.add("default", file('opencsv-3.6.jar'))
May I know how to ignore testing this module?
Gradle 1.11 gives me a deprecation warning:
robert#pferdeapfel:~/prj> gradle --version | grep Gradle
Gradle 1.11
robert#pferdeapfel:~/prj> gradle compileJava
Converting class org.gradle.api.internal.file.DefaultSourceDirectorySet to File using
toString() method has been deprecated and is scheduled to be removed in Gradle 2.0.
Please use java.io.File, java.lang.String, java.net.URL, or java.net.URI instead.
:compileAcctJava
:processAcctResources UP-TO-DATE
:acctClasses
:resources
:acct UP-TO-DATE
:beans UP-TO-DATE
:svninfo UP-TO-DATE
:settings UP-TO-DATE
:compileJava UP-TO-DATE
BUILD SUCCESSFUL
Total time: 10.865 secs
and Gradle 2.0 fails the build:
robert#pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle --version | grep Gradle
Gradle 2.0
robert#pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle -i compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':compileAcctJava'.
> Cannot convert the provided notation to a File or URI: acct Java source.
The following types/formats are supported:
- A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
- A String or CharSequence URI, e.g 'file:/usr/include'
- A File instance.
- A URI or URL instance.
* 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: 3.676 secs
However, I have no idea why and where in my build script the problem is.
I have defined source sets as described in http://www.gradle.org/docs/current/userguide/java_plugin.html#sec%3asource_sets like this cause my project does not follow the default project layout.
sourceSets {
...
acct {
java {
srcDir "src"
srcDirs("src") {
include "my/program/some/package/Acct.java"
}
}
}
...
}
I do have some dependencies defined, but not for acct; this is just a simple enum that's used as a base for code generation. It has no dependencies. Even if I add a dummy dependency like below, I get the same error.
dependencies {
...
acctCompile junit
...
}
How can I fix this or how can I find out more about what exactly went wrong?
I don't find the output of Gradle's --debug and --stacktrace helpful at all.
There is no such notation as srcDirs("src") { include "my/program/some/package/Acct.java" }. Try:
sourceSets {
acct {
java {
srcDirs = ["src"] // replaces default rather than adding another dir
include "my/program/some/package/Acct.java"
}
}
}
I am getting the following error when I try to build sliding menu project. This project was used in eclipse but I used default import in android studio to get this project.
:slidingMenu:lint FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':slidingMenu:lint'.
[Ljava/util/HashMap$Entry;
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: 9.59 secs Could not execute build using Gradle
distribution
'http://services.gradle.org/distributions/gradle-1.9-all.zip'.
Running with --stacktrace didn't give any new info.
I've tried adding an ignore as mentioned in this answer - gradle build fails on lint task but that doesn't help.
Did the import create a build.gradle in slidingmenu? That might be the problem if it is not defined as a library:
apply plugin: 'android-library'
I don't have it set up as a library in this way though. I include it in the app's build.gradle:
dependencies {
// ...
compile project(':slidingmenu:library')
}
and in settings.gradle:
include ':slidingmenu:library'