I am new to Gradle.I am using Gradle 4.3 version.I am trying to configure a spring -boot application using gradle but it getting failed during project build phase.
Please find below my build.gradle file:
plugins {
id "org.springframework.boot" version "1.5.10.RELEASE"
}
apply plugin: 'java-library'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
testImplementation 'junit:junit:4.12'
compile(
'org.springframework.boot:spring-boot-starter-actuator',
'org.springframework.boot:spring-boot-starter-web',
'org.apache.tomcat.embed:tomcat-embed-jasper',
'org.springframework.boot:spring-boot-starter-thymeleaf'
)
}
}
During gradle building from eclipse I am using build command,I am getting following error in eclipse console:
Working Directory: D:\Maven_Workspace\AddGradleViewer
Gradle User Home: C:\Users\Sumit\.gradle
Gradle Distribution: Local installation at C:\Users\Sumit\.gradle\wrapper\dists\gradle-4.3
Gradle Version: 4.3
Java Home: C:\Java\Java8\Jre8
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: true
Offline Mode Enabled: false
Gradle Tasks: build
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter-actuator:.
Searched in the following locations:
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.pom
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.jar
Required by:
project :
> Could not find org.springframework.boot:spring-boot-starter-web:.
Searched in the following locations:
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.pom
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.jar
Required by:
project :
> Could not find org.apache.tomcat.embed:tomcat-embed-jasper:.
Searched in the following locations:
https://repo1.maven.org/maven2/org/apache/tomcat/embed/tomcat-embed-jasper//tomcat-embed-jasper-.pom
https://repo1.maven.org/maven2/org/apache/tomcat/embed/tomcat-embed-jasper//tomcat-embed-jasper-.jar
Required by:
project :
> Could not find org.springframework.boot:spring-boot-starter-thymeleaf:.
Searched in the following locations:
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-thymeleaf//spring-boot-starter-thymeleaf-.pom
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-thymeleaf//spring-boot-starter-thymeleaf-.jar
Required by:
project :
Can anyone provide any suitable solution to this?
Related
I am getting below error when Jenkins pipeline is run :
Welcome to Gradle 7.0!
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'Auth-mapper'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.7.7.
Required by:
project :
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.7.7.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/2.7.7/spring-boot-gradle-plugin-2.7.7.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/2.7.7/spring-boot-gradle-plugin-2.7.7.pom'.
> Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.32.215] failed: connect timed out
> Could not resolve io.spring.gradle:dependency-management-plugin:1.1.0.
Required by:
project :
> Could not resolve io.spring.gradle:dependency-management-plugin:1.1.0.
my build.gradle file is having these entries :
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.7.7"
classpath "io.spring.gradle:dependency-management-plugin:1.1.0"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0"
}
apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"
apply plugin: "org.sonarqube"
When I run this application in local then its working fine but when I try deploying it to openshift via Jenkins then in the build step its failing due to the above issue.
Below configuration in gradle.properties based on above comments worked for me ...
systemProp.https.proxyHost
systemProp.https.proxyPort
systemProp.http.nonProxyHosts
The above properties values needs to be set based on company specific configuration.
I've created a demo Gradle project called test-jdbc-demo from Spring using some dependencies and change nothing, just unziped and imported on Intellij using Open -> build.gradle file and tried too using Import from default Intellij window. When imported the project is not build and a error about gradle dependencies occurs. I'm using Intellij 2019.3, JDK 1.8 on Ubuntu.
Error
FAILURE: Build failed with an exception.
* Where:
Build file '/home/augusto.cadini/projects/Spring Applications/test-jdbc-demo/build.gradle' line: 2
* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.2.4.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.2.4.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository
* 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
CONFIGURE FAILED in 208ms
build.gradle
plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.jdbc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
This drove me crazy. I was getting the same errors (this is from a clean project generated from Spring Initializr). Turned out it was an issue with the Gradle version. When I ran a build from the command line, I got the following error message
Once I updated gradle it build with no issues.
Looking to import the eXist database, as well as additional dependencies.
What repositories work best for this requirements?
stack trace for build:
thufir#dur:~/NetBeansProjects/twitterBaseX$
thufir#dur:~/NetBeansProjects/twitterBaseX$ gradle clean build
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.exist-db.thirdparty.com.thaiopensource:jing:20151127.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/exist-db/thirdparty/com/thaiopensource/jing/20151127/jing-20151127.pom
- https://repo.maven.apache.org/maven2/org/exist-db/thirdparty/com/thaiopensource/jing/20151127/jing-20151127.jar
- https://mvnrepository.com/org/exist-db/thirdparty/com/thaiopensource/jing/20151127/jing-20151127.pom
- https://mvnrepository.com/org/exist-db/thirdparty/com/thaiopensource/jing/20151127/jing-20151127.jar
- https://jcenter.bintray.com/org/exist-db/thirdparty/com/thaiopensource/jing/20151127/jing-20151127.pom
- https://jcenter.bintray.com/org/exist-db/thirdparty/com/thaiopensource/jing/20151127/jing-20151127.jar
Required by:
project : > org.exist-db:exist-core:5.2.0
> Could not find org.exist-db.thirdparty.javax.xml.xquery:xqjapi:1.0-fr.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/exist-db/thirdparty/javax/xml/xquery/xqjapi/1.0-fr/xqjapi-1.0-fr.pom
- https://repo.maven.apache.org/maven2/org/exist-db/thirdparty/javax/xml/xquery/xqjapi/1.0-fr/xqjapi-1.0-fr.jar
- https://mvnrepository.com/org/exist-db/thirdparty/javax/xml/xquery/xqjapi/1.0-fr/xqjapi-1.0-fr.pom
- https://mvnrepository.com/org/exist-db/thirdparty/javax/xml/xquery/xqjapi/1.0-fr/xqjapi-1.0-fr.jar
- https://jcenter.bintray.com/org/exist-db/thirdparty/javax/xml/xquery/xqjapi/1.0-fr/xqjapi-1.0-fr.pom
- https://jcenter.bintray.com/org/exist-db/thirdparty/javax/xml/xquery/xqjapi/1.0-fr/xqjapi-1.0-fr.jar
Required by:
project : > org.exist-db:exist-core:5.2.0
* 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 3s
2 actionable tasks: 2 executed
thufir#dur:~/NetBeansProjects/twitterBaseX$
it's only the import for exist-db which seems to be causing trouble:
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* User Manual available at https://docs.gradle.org/5.4.1/userguide/tutorial_java_projects.html
*/
plugins {
// Apply the java plugin to add support for Java
id 'java'
// Apply the application plugin to add support for building an application
id 'application'
}
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
//
//maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://mvnrepository.com/" }
jcenter()
}
dependencies {
// This dependency is found on compile classpath of this component and consumers.
implementation 'com.google.guava:guava:27.0.1-jre'
// Use TestNG framework, also requires calling test.useTestNG() below
testImplementation 'org.testng:testng:6.14.3'
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.1'
compile group: 'org.basex', name: 'basex', version: '9.2.4'
compile group: 'net.sf.xmldb-org', name: 'xmldb-api', version: '1.7.0'
// https://mvnrepository.com/artifact/org.exist-db/exist-core
compile group: 'org.exist-db', name: 'exist-core', version: '5.2.0'
}
// Define the main class for the application
mainClassName = 'twitterBaseX.App'
test {
// Use TestNG for unit tests
useTestNG()
}
as commenting out that compile group allows a clean build. Presumably it's a question of adding the correct repo's properly?
For eXist-db 5.x.x you need two repositories:
Maven Central for the eXist-db artifacts themselves.
eXist-db's Repository (http://repo.evolvedbinary.com/repository/exist-db/) for some third-party artifacts which cannot be published to Maven Central as they do not meet the requirements for Maven Central.
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.
When compiling and building my android app, an error as shown below keeps occurring. I have been using this stack overflow answer to solve the error and exclude the duplicate files.
Here is the error I get when I try to build my project.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt
File1: /Users/tomfinet/.gradle/caches/modules-2/files-2.1/com.google.appengine/appengine-api-1.0-sdk/1.9.28/e92c18272b555027d9ec666e7a89162f10638314/appengine-api-1.0-sdk-1.9.28.jar
File2: /Users/tomfinet/.gradle/caches/modules-2/files-2.1/com.google.appengine/appengine-endpoints/1.9.28/bf2e8a74bd28e388b3487fc78a0c7adfa592fd5d/appengine-endpoints-1.9.28.jar
When I run the terminal command ./gradlew dependencies as instructed in the stack overflow answer, I am supposed to see the entire dependency tree for my project.
However all I see is this:
Downloading https://services.gradle.org/distributions/gradle-2.10-all.zip
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /Users/tomfinet/.gradle/wrapper/dists/gradle-2.10-all/a4w5fzrkeut1ox71xslb49gst/gradle-2.10-all.zip to /Users/tomfinet/.gradle/wrapper/dists/gradle-2.10-all/a4w5fzrkeut1ox71xslb49gst
Set executable permissions for: /Users/tomfinet/.gradle/wrapper/dists/gradle-2.10-all/a4w5fzrkeut1ox71xslb49gst/gradle-2.10/bin/gradle
google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
please apply google-services plugin at the bottom of the build file.
Incremental java compilation is an incubating feature.
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
No configurations
BUILD SUCCESSFUL
Total time: 53.171 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html
Here is my gradle file for the backend:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.28'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.28'
compile 'com.google.appengine:appengine-endpoints:1.9.28'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.28'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:5.0.3'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
So how do I resolve this conflict between the dependencies? I am pretty sure I have to exclude the conflicting files. But how do I find the files that are causing this?