I used filteringCharset = 'UTF-8' because of encoding problems in ProcessResources in build.gradle. This build succeeded on my desktop, but failed on Travis CI. I guess this is the problem with Travis CI's Gradle. So I tried to update the version but could not find any information. Is this the problem with the Gradle version? If yes, what can I do?
Travis build error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/EntryPointKR/K-Security/build.gradle' line: 43
* What went wrong:
A problem occurred evaluating root project 'K-Security'.
> No such property: filteringCharset for class: org.gradle.language.jvm.tasks.ProcessResources_Decorated
Full travis build log: https://travis-ci.org/EntryPointKR/K-Security/builds/201771722
.travis.yml:
language: java
sudo: false
jdk:
- oraclejdk8
addons:
apt:
packages:
- oracle-java8-installer
Problem code in build.gradle
processResources {
filteringCharset = 'UTF-8' // Here
filter ReplaceTokens, tokens: [
"version" : project.version,
"pluginName": rootProject.name,
"mainClass" : "cloud.swiftnode.ksecurity.KSecurity",
"author" : "EntryPoint"
]
}
This is very likely due to a mismatch between your gradle version and the gradle version installed in the java image. It was introduced in Gradle 2.14. The easiest fix is to use gradle wrapper to enforce the same version in both environments.
Simply add the wrapper task:
task wrapper(type: Wrapper) {
gradleVersion = '3.3'
}
It should be possible to run gradle wrapper in before_install, or simply bundle the gradle-wrapper jar with your project. Travis CI will detect gradle wrapper and use gradlew instead of gradle.
If you are using Windows on your local machine, make sure you commit the gradlew script with executable flag.
Related
Recently I downloaded Spring Boot 3 to test the embedded GraalVM. I run the `./gradlew native compile command the result is:
$ ./gradlew nativeCompile
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':nativeCompile'.
> Invalid GAV coordinates: groovy:it_groovy_comparre: (expected format: groupId:artifactId: version)
....
BUILD FAILED in 752ms
What is my problem with dependencies? When I run that command in debug mode there is nothing new except this error.
NOTE:
my $JAVA_HOME variable value is: /home/<my username>/.jdks/graalvm-ce-java17-22.3.0/, which point to a Graalvm java
my build automation tool is Gradle.
When I tested the command in groovy the result was the same
I found the solution.
Firstly I added a version to my build.gradle file like this :
plugins {
// ...
}
group = 'groovy'
version = '1' // <-------------- HERE
sourceCompatibility = '17'
configurations {
//...
}
Just before executing the command ./gradlew nativeCompile, I ran the following two commands :
$ ./gradlew processAot
...
$ ./gradlew processTestAot
...
After that, everything works fine.
This is the error I get from the console of the program and it won't let me even import the gradle to Eclipse
Generating app in C:\Users\mrgnh\Desktop\libGDXstuff
Executing 'C:\Users\mrgnh\Desktop\libGDXstuff/gradlew.bat clean --no-daemon'
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/6.7.1/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
FAILURE: Build failed with an exception.
Where:
Settings file 'C:\Users\mrgnh\Desktop\libGDXstuff\settings.gradle'
What went wrong:
Could not compile settings file 'C:\Users\mrgnh\Desktop\libGDXstuff\settings.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 60
It turns out I am blind and that libGDX does not support JDK 16 only 8-15
So when creating the gradle with the JDK 16 gradle System it wasn't working out
Try to change to latest gradle website version of gradle in file: Gradle -> Wrapper -> gradle-wrapper.properties
It helped me.
I am facing an issue with my gradle project during migration to Gradle 5.1 from Gradle 4.10.2 :
Issue :
./gradlew clean build
> Task :subprojects:lib-abc-admin:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':subprojects:lib-abc-admin:compileJava'.
> Could not resolve all files for configuration ':subprojects:lib-abc-admin:compileClasspath'.
> Could not find org.glassfish.jersey:jersey-bom:.
Required by:
project :subprojects:lib-abc-admin
BUILD FAILED in 2s
In previous version Gradle 4.10.2, this error was getting circumvented by the following switch:
enableFeaturePreview("IMPROVED_POM_SUPPORT")
But in gradle 5 this switch has been deprecated, seems like this doesn't work anymore and I am getting the errors.
Any alternatives / suggestions / solutions ?
Toolchain Details :
------------------------------------------------------------
Gradle 5.1
------------------------------------------------------------
Kotlin DSL: 1.1.0
Kotlin: 1.3.11
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.1 (Oracle Corporation 11.0.1+13-LTS)
OS: Linux 4.19.8-200.fc28.x86_64 amd64
From gradle issue:
Different approaches were tried for supporting BOMs.
In Gradle 5.0, through feedback from the community (see #4422), we ended up deciding on an explicit notation to import a BOM.
So you will need to update dependencies on modules that are BOMs to that notation.
See documentation for details.
And since the IMPROVED_POM_SUPPORT feature is now enabled by default, you can remove the enableFeaturePreview("IMPROVED_POM_SUPPORT") line from your settings.gradle(.kts)
Gradle throws a NoClassDefFoundError when trying to execute a grgit task.
Start of build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'org.ajoberstar:gradle-git:1.2.0'
}
}
apply plugin: 'com.android.application'
//
//
import org.ajoberstar.grgit.*
task clone << {
File dir = new File('contrib/otherstuff')
if(!dir.exists()) {
def grgit = Grgit.clone(dir: dir, uri: 'https://github.com/someguy/otherstuff.git')
}
// TODO else (pull)
}
project.afterEvaluate {
preBuild.dependsOn clone
}
// rest omitted
Output:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:src:myproject:clone FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/src/myproject/build.gradle' line: 20
* What went wrong:
Execution failed for task ':src:myproject:clone'.
> java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
* 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: 16.937 secs
Line 20 is the call to Grgit.clone().
Do I need to add groovy as a build dependency (which the error message seems to indicate)? How and where would I add it?
EDIT: gradle version is 1.10, if it matters.
As #user149408 pointed out the Gradle version (v1.10 vs v2.10) mismatch, I dug a little bit further:
gradle-git-plugin commit for v0.7.0 specifies the Gradle version used (v1.11), so the build with v1.10 works fine.
Because the Gradle plugin always built with compile localGroovy() and compile gradleApi() which comes from Gradle, then if it builds with Gradle 2.x, it would incur the Groovy mismatch error.
What went wrong: Execution failed for task ':src:myproject:clone'.
java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
In fact, the combo of Gradle v2.10 and gradle-git v1.2.0 just works fine.
Some sample build.gradle similar structure as in the question.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ajoberstar:gradle-git:1.2.0'
}
}
import org.ajoberstar.grgit.*
task clone << {
File dir = new File('contrib/gs-spring-boot')
if(!dir.exists()) {
def grgit = Grgit.clone(dir: dir, uri: 'https://github.com/chenrui333/gs-spring-boot.git')
}
// TODO else (pull)
}
./gradlew clone would give you:
$ ls contrib/gs-spring-boot/
CONTRIBUTING.adoc LICENSE.code.txt LICENSE.writing.txt README.adoc complete initial test
Hope it helps!
I’ve managed to solve it.
grgit-1.2.0 appears to depend on groovy. Adding a classpath entry for groovy in the buildscript/dependencies block resulted in a different error:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:src:myproject:clone FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/src/myproject/build.gradle' line: 23
* What went wrong:
Execution failed for task ':src:myproject:clone'.
> java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for org.ajoberstar.grgit.auth.AuthConfig$Option do not match. Expected -1 but got 2
* 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: 12.295 secs
Further research revealed that this might stem from a version incompatibility (as I’m stuck with Gradle 1.10 for other reasons).
Eventually I solved it by going back to grgit-0.7.0. Now my git task works and the repo gets cloned.
In shell I typed gradle cleanJar in the Impatient/part1 directory. The output is below. The error is "class file for org.apache.hadoop.mapred.JobConf not found". Why did it fail to compile?
:clean UP-TO-DATE
:compileJava
Download http://conjars.org/repo/cascading/cascading-core/2.0.1/cascading-core-2.0.1.pom
Download http://conjars.org/repo/cascading/cascading-hadoop/2.0.1/cascading-hadoop-2.0.1.pom
Download http://conjars.org/repo/riffle/riffle/0.1-dev/riffle-0.1-dev.pom
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.pom
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.6.1/slf4j-parent-1.6.1.pom
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.pom
Download http://conjars.org/repo/thirdparty/jgrapht-jdk1.6/0.8.1/jgrapht-jdk1.6-0.8.1.pom
Download http://repo1.maven.org/maven2/org/codehaus/janino/janino/2.5.16/janino-2.5.16.pom
Download http://conjars.org/repo/cascading/cascading-core/2.0.1/cascading-core-2.0.1.jar
Download http://conjars.org/repo/cascading/cascading-hadoop/2.0.1/cascading-hadoop-2.0.1.jar
Download http://conjars.org/repo/riffle/riffle/0.1-dev/riffle-0.1-dev.jar
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar
Download http://conjars.org/repo/thirdparty/jgrapht-jdk1.6/0.8.1/jgrapht-jdk1.6-0.8.1.jar
Download http://repo1.maven.org/maven2/org/codehaus/janino/janino/2.5.16/janino-2.5.16.jar
/home/is_admin/lab/cascading/Impatient/part1/src/main/java/impatient/Main.java:50: error: cannot access JobConf
Tap inTap = new Hfs( new TextDelimited( true, "\t" ), inPath );
^
class file for org.apache.hadoop.mapred.JobConf not found
1 error
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':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.
BUILD FAILED
Total time: 22.599 secs
try using Java 6 , gradle has some known issues with java 7
Add hadoop-core-1.x.y.jar from hadoop distribution to path.
This worked for me in CoPA example. I added to eclipse build path.
Add this to gradle dependencies{} section
compile( group: 'org.apache.hadoop', name: 'hadoop-core', version: '1.2.0' )
It seems like class not found, please check libraries in build path entries.
I had the same issue today trying the Cascading for the Impatient tutorial. I have solved adding the following to my build.gradle in the dependenciessection :
compile 'org.apache.hadoop:hadoop-client:2.3.0'
I wanted to use Hadoop 2.3.0, but I guess that you can choose your own version of Hadoop.
PS : In order to use the first hadoop-mapred package, you have to add the following instead :
compile 'org.apache.hadoop:hadoop-mapred:0.22.0'
You can find all the repos you might need for Hadoop here.
Thanks Lalit,
Adding the below line did the trick for me without have to change any java version..
compile( group: 'org.apache.hadoop', name: 'hadoop-core', version: '1.2.0' )
Alternatively, I can even add the hadoop-core jar in the class path and mention that in the gradle path