Gradle build is getting failed - java

I am quite new to gradle world and I am trying to build a java project and publish the resulting artifacts to the repository.
As part of the build, I am getting the below error message, some pointers on how to fix the below issue would be helpful.
Gradle Build:
$ gradle build --info
Initialized native services in: /var/lib/jenkins/.gradle/native
The client will now receive all logging from the daemon (pid: 4587). The daemon log file: /var/lib/jenkins/.gradle/daemon/4.9/daemon-4587.out.log
Starting 42nd build in daemon [uptime: 4 hrs 26 mins 46.465 secs, performance: 99%]
Using 4 worker leases.
Starting Build
Settings evaluated using settings file '/var/lib/jenkins/gradle_projects/settings.gradle'.
Projects loaded. Root project using build file '/var/lib/jenkins/gradle_projects/build.gradle'.
Included projects: [root project 'hello-world']
> Configure project :
Evaluating root project 'hello-world' using build file '/var/lib/jenkins/gradle_projects/build.gradle'.
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/gradle_projects/build.gradle' line: 32
* What went wrong:
A problem occurred evaluating root project 'hello-world'.
> Could not find method artifactory() for arguments [build_en65a4pmtkipo6cwvlcm8w7ky$_run_closure3#3ea141a7] on root project 'hello-world' of type org.gradle.api.Project.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 0s

This error is because you are trying to configure the Artifactory plugin ( artifactory block) but you did not apply the Artifactory plugin to your project.
Try to import the plugin as follow:
buildscript {
// EDIT
repositories {
// ...
jcenter()
}
dependencies {
// ...
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release" // <- this line is missing in your script
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory" // <-- this one is missing in your script
Refer to the plugin official documentation for full configuration examples : https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin

Related

What is causes a ModuleVersionNotFoundException in Gradle?

I've used Gradle before, but have never configured it myself. I'm running openjdk 11.0.4 and have installed Gradle using the official install guide, including adding it to the windows path. All I've been doing is adding the line:
'''
implementation 'com.github.kittinunf.fuel:fuel:2.2.0'
to my build.gradle file. I'm editing using Intellij. Here is my full build.gradle file:
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
}
group 'lastname'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'com.github.kittinunf.fuel:fuel:2.2.0'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
When I try to sync the project I get the following from my Gradle tab
gradle_tab_view
The build output I get is this:
4:20:29 PM: Executing tasks ':classes :testClasses'...
> Task :compileKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlin'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.github.kittinunf.fuel:fuel:2.2.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/github/kittinunf/fuel/fuel/2.2.0/fuel-2.2.0.pom
- https://repo.maven.apache.org/maven2/com/github/kittinunf/fuel/fuel/2.2.0/fuel-2.2.0.jar
Required by:
project :
* 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 0s
1 actionable task: 1 executed
4:20:30 PM: Tasks execution finished ':classes :testClasses'.
Any advice on what could be broken or maybe what clearly isn't implemented would be appreciated, this has greatly hindered my work flow, and I feel like it has to be something small or stupid that I'm overlooking. I feel like I'm at war with Gradle to get Fuel to work in my project.
The error output means that Gradle could not find the Fuel dependency in the two locations is searched. Both locations are in https://repo.maven.apache.org/maven2/, which is Maven Central. Gradle looks in this repository as you have told it to through repositories { mavenCentral() }.
However, Fuel is not published to Maven Central. If you use a search site like mvnrepository, you will see where it was found. In this case it says:
Note: this artifact it located at Spring Lib Release repository
(https://repo.spring.io/libs-release/)
But his is misleading, because that is just a mirror as some Spring library apparently depends on it. If you head over to the Github page for Fuel, you will see that it is in reality deployed to Jitpack. So the correct solution is to add Jitpack to the list of repositories in Gradle:
repositories {
maven {
name "jitpack"
url "https://www.jitpack.io"
}
}
This is not all that clear from the Github page as is is only explained in the section for snapshot releases. But it is not all that uncommon to have to do a bit of detective work to track down which repository to use for a given dependency when it is not present in any of the common ones.
By the way, testCompile is deprecated and you should use testImplementation. And since this is a Kotlin project, you will probably want to switch from the Groovy DSL to Kotlin DSL at some point.

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

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.

JavaFXPorts and NetBeans Gluon Plugin

I'm getting following exception while building Javafx Application into Android.
error: Error: No resource found that matches the given name (at 'icon' with value '#mipmap/ic_launcher').
:processAndroidDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processAndroidDebugResources'.
> Process 'command 'E:\Android\android-sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1
* 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: 1 mins 24.005 secs
Build failure (see the Notifications window for stacktrace): gradle :android
and I'm had installed android sdk and pointed to ANDROID_HOME. this my build script in build.gradle.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b4'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
}
mainClassName = 'com.javafxport.JavaFXPort'
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
}
}
I'm trying to install very simple javafx application into my android device. please help me with advance.
First of all, check that your Gluon plugin for NetBeans is updated. Currently you can use version 1.0.2, that will provide you with a more updated version of the plugin:
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b9'
}
Actually, according to this, you can update that manually to:
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.1'
}
Now check on Android SDK, using SDK Manager, that you have installed sdks version 22, and building tools version 22, but not version 23, which is for the new Android M, not supported yet by JavaFXPorts.

Gradle 'Could not resolve all dependencies for configuration' in Jersey/JAX-RS project

I would like to put JSON dependency in the build.gradle, in order to fix the error MessageBodyWriter not found for media type=application/json.
In my previous question I learned that it was very likely that I did not include JSON as dependency in my build.gradle file.
I added the dependency as shown below (line 8, last compile)
apply plugin: 'war'
apply plugin: 'jetty'
dependencies {
compile fileTree(dir: 'lib', include: '**/*.jar')
compile(project(":qa-common"))
compile(project(":alm"))
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.3.10'
}
jettyRun {
httpPort = 8080
reload = 'automatic'
scanIntervalSeconds = 2
daemon = false
}
Now I am getting the error of Could not resolve all dependencies for configuration'
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':qa-automation-console:compile'.
> Cannot resolve external dependency org.glassfish.jersey.media:jersey-media-json-jackson:2.3.10 because no repositories are defined.
Required by:
qaauto:qa-automation-console:unspecified
* 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: 5.273 secs
I am checking whether I have included the correct version of gradle and Jersey (in web.xml I see 2.5 but 2.5 still gives the same error). In my jersey server side code the only package related to jersey was import org.glassfish.jersey.server.mvc.Viewable;
Anyone give me a clue what I need to add?
Define repositories in your build.gradle like following.
repositories {
maven {
url "http://repo1.maven.org/maven2"
}
}
Or following
repositories {
mavenCentral()
}
Gradle Help Chapter 8. Dependency Management Basics 8.5. Repositories gives other examples.
You should also change your dependency according to existing versions. I linked version page since you request "version 2.3.10" which does not exist in maven repository.
dependencies {
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.5'
}

Categories