"Could not resolve all files for configuration" after upgrading Gradle - gradle

I have a Gradle script that downloads the latest snapshot artifact from a Nexus server. It's been working fine with Gradle 5.4 but doesn't seem to be willing to work after upgrading to Gradle 6.5.
These are the build.gradle contents:
apply plugin: "java"
repositories {
maven {
url "https://somerepo.com/repository/app-snapshot/"
credentials {
username 'a-user'
password 'a-password'
}
authentication {
basic(BasicAuthentication)
}
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
configurations {
component
}
dependencies {
component group: "com.bla.ble, name: "component-name", version: "${version}-SNAPSHOT"
}
task copyComponent(type: Copy) {
from configurations.component
into "/some/local/path"
}
Gradle fails as follows:
Execution failed for task ':copyWorkflow'.
> Could not resolve all files for configuration ':workflow'.
> Could not find com.bla.ble:component-name:3.2.0-SNAPSHOT.
Searched in the following locations:
- https://somerepo.com/repository/app-snapshot/com/bla/ble/component-name/3.2.0-SNAPSHOT/maven-metadata.xml
- https://somerepo.com/repository/app-snapshot/com/bla/ble/component-name/3.2.0-SNAPSHOT/component-name-3.2.0-20201130.163046-11.pom
Required by:
project :
I've I navigate to https://somerepo.com/repository/app-snapshot/com/bla/ble/component-name/3.2.0-SNAPSHOT/maven-metadata.xml this provides a valid metadata file and points to a snapshot that actually has a valid file.
I've then tried downgrading again to Gradle 5.4 and worked OK. I was also trying to find any deprecated options in Gradle 6.x but couldn't find what it makes it fail.

Found the solution through this post: https://discuss.gradle.org/t/how-to-fetch-maven-artifact-without-pom-file-in-gradle-6-0/33836/2
Short history: A breaking change introduced in Gradle 6.x prevents the artifacts from being downloaded if the POM is not present. To go around this requirement, the following needs to be added to the maven definition:
metadataSources {
artifact()
}
More info: https://docs.gradle.org/current/userguide/upgrading_version_5.html?_ga=2.181891495.1612153887.1606754101-263409462.1606754101#maven_or_ivy_repositories_are_no_longer_queried_for_artifacts_without_metadata_by_default

Related

Switch a Gradle-based Vaadin 22 app to Vaadin 23 beta

I am a Gradle newbie, having used Maven in the past.
I successfully established a Vaadin 22.0.5 project using the Vaadin Latest - Gradle starter project downloaded from Hello World Starters page. The project successfully builds and runs using gretty > apprun in IntelliJ 2021.1 EAP Ultimate edition.
👉 How do I alter the project to use the current beta version of the next version, Vaadin 23.0.0.beta2, as listed on the Vaadin releases page?
First attempt
I changed the gradle.properties file which consists of this single line:
vaadinVersion=22.0.5
… to this:
vaadinVersion=23.0.0.beta2
I clicked the floating windoid, Load Gradle Changes.
I immediately see this error appear in the IDE’s Build pane:
Build file '/Users/my_user/IdeaProjects/GetJava/build.gradle' line: 11
Plugin [id: 'com.vaadin', version: '23.0.0.beta2'] was not found in any of the following sources:
* 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.
Second attempt
After receiving Answer by cfrick, I did the following.
If found this at the top of the build.gradle file:
buildscript {
repositories {
maven { setUrl("https://maven.vaadin.com/vaadin-prereleases") }
maven { url "https://plugins.gradle.org/m2/" }
}
}
So I made no edits there, as seemed to be accomplishing the same thing as the first part of the Answer.
I changed the entirety of the settings.gradle file from this:
pluginManagement {
plugins {
id 'com.vaadin' version "${vaadinVersion}"
}
}
… to this:
pluginManagement {
repositories {
gradlePluginPortal()
maven {
url = "https://maven.vaadin.com/vaadin-prereleases"
}
}
plugins {
id 'com.vaadin' version "${vaadinVersion}"
}
}
I changed the gradle.properties file which consists of this single line:
vaadinVersion=22.0.5
… to this, using beta1 rather than beta2 seen above.
vaadinVersion=23.0.0.beta1
After executing Tasks > build > clean, I get a BUILD SUCCESSFUL message.
But when I execute Gretty > apprun, I get the following error message.
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.vaadin:vaadin-bom:23.0.0.beta1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/vaadin/vaadin-bom/23.0.0.beta1/vaadin-bom-23.0.0.beta1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
> Could not find com.vaadin:vaadin-core:.
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Pre-release versions are released first in Vaadins own pre-release
repository. You would have to add the repository if you need access to
releases, that have not yet hit the public repos:
In build.gradle expand repositories by:
repositories {
// ...
maven {
url = "https://maven.vaadin.com/vaadin-prereleases"
}
}
In the settings.gradle add a repositories block too:
pluginManagement {
repositories {
gradlePluginPortal()
maven {
url = "https://maven.vaadin.com/vaadin-prereleases"
}
}
plugins {
id 'com.vaadin' version "${vaadinVersion}"
}
}

Failed to apply plugin 'no.nils.wsdl2java'. Configuration with name 'compile' not found

when migrating to gradle 7.x getting below error
* What went wrong:
An exception occurred applying plugin request [id: 'no.nils.wsdl2java', version: '0.12']
> Failed to apply plugin 'no.nils.wsdl2java'.
> Configuration with name 'compile' not found.
Below is wsdl2java added in build.gradle
plugins {
id("no.nils.wsdl2java") version "0.12"
`java-library`
}
buildscript {
dependencies {
classpath("no.nils:wsdl2java:0.12")
}
}
how to fix this?
no.nils.wsdl2java is not compatible with Gradle 7 and is no longer maintained. See the README in the project. The compile configuration has long been deprecated and was finally removed in Gradle 7.
You can use io.mateo.cxf-codegen in place of no.nils.wsdl2java. It is a Gradle port of the Maven CXF codegen plugin.
plugins {
id "io.mateo.cxf-codegen" version "1.0.1"
}
https://github.com/ciscoo/cxf-codegen-gradle
https://ciscoo.github.io/cxf-codegen-gradle/docs/current/user-guide/
Note, I am the author of the plugin.

gradle can't download ua-parser file

I'm trying to test some jenkins job seed dsls and for that I needed to download in gradle all plugins jenkins had, one of them was blueocean and in my build.gradle I've got this line
testPlugins 'io.jenkins.blueocean:blueocean:1.23.2'
and I get thrown this exception
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find ua_parser:ua-parser:1.3.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- https://repo.maven.apache.org/maven2/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
- http://repo.jenkins-ci.org/releases/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- http://repo.jenkins-ci.org/releases/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
- https://jcenter.bintray.com/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- https://jcenter.bintray.com/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
Required by:
project : > io.jenkins.blueocean:blueocean:1.23.2 > io.jenkins.blueocean:blueocean-rest-impl:1.23.2
I tried running with gradlew 4.8.1 and 6.0.1
I tried addint the ua-parser to build.gradle
compile group: 'ua_parser', name: 'ua-parser', version: '1.3.0'
I tried removing all gradle cache and refresh dependencies
rm -rf ~/.gradle/cache
./gradlew test --refresh-dependencies # or ./gradlew build ..
I disabled the vpn so it wasn't some firewall not allowing me to connect to the site, maybe I have some outdated gradle repository stored ? (I'm not familiar with gradle yet, so maybe something simple is escaping my sight)
EDIT 1:
I think this might be related to missing repository so tried adding new one by hand I found the https://github.com/jenkinsci/blueocean-plugin and tried add it to settings.gradle
sourceControl {
gitRepository("https://github.com/jenkinsci/blueocean-plugin.git") {
producesModule("org.gradle.blueocean:utilities")
}
}
and then referencing in build.gradle
dependencies {
...
implementation 'org.gradle.blueocean:utilities'
but doesn't seem to work, does anyone know how to add/where to search for gradle repositories (specifically with blueocean poms)
had to add those lines in repositories in build.gradle
repositories {
mavenCentral()
maven { url 'http://repo.jenkins-ci.org/releases/' }
maven { url 'https://mvnrepository.com/artifact/io.jenkins.blueocean' }
maven { url 'https://mvnrepository.com/artifact/ua_parser/ua-parser' }
maven { url 'https://mvnrepository.com/artifact' }
maven { url 'https://maven.twttr.com/' }

Gradle Dependency Problem when Upgrading to Gradle 6

I have a gradle Project where I have a dependency on "hudson-core 3.3.3"
compile group: 'org.eclipse.hudson', name: 'hudson-core', version: '3.3.3'
This works without a problem when using Gradle 5.6.2
When I upgrade to Gradle 6.0.1 I receive the following error:
Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
Required by:
project : > org.eclipse.hudson:hudson-core:3.3.3
project : > org.eclipse.hudson:hudson-core:3.3.3 > org.eclipse.hudson:hudson-cli:3.3.3
> Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
> inconsistent module metadata found. Descriptor: org.eclipse.hudson:hudson-remoting:3.0.4-SNAPSHOT Errors: bad version: expected='3.0.3' found='3.0.4-SNAPSHOT'
The Repository is always the same:
repositories {
mavenCentral()
maven {
url 'http://repo.jenkins-ci.org/public/'
}
}
Any Ideas why this error happens?
As said by #ToYonos, the problem is in the dependency itself.
Not perfect solutions, but 2 workarounds can be done as explained in Gradle's documentation (v6.7.1):
Exclude that transitive dependency, for example in the current Gradle versions using implementation instead of compile:
implementation('org.eclipse.hudson:hudson-core:3.3.3') {
exclude group: 'org.eclipse.hudson'
exclude module: 'hudson-remoting'
}
Override that transitive dependency version:
implementation('org.eclipse.hudson:hudson-remoting') {
version {
strictly '3.0.2' // As 3.0.3 is having the issue
}
}
In the pom.xml file of hudson-remoting 3.0.3, the version is <version>3.0.4-SNAPSHOT</version>
The issue is quite clear.
I tried with an old Gradle 4.4.1 and I am having the exact same issue. Likewise with Gradle 5.1.1 and your version, 5.6.2
I'm quite sure that if you clean your artefact cache for Gradle 5.6.2, it won't work anymore.
The error is on the repository side.
Another option is to define a repository that will download only a jar:
repositories {
mavenCentral() {
name = "Download only jar repo"
metadataSources { artifact() }
content {
// Use this repository only for org.eclipse.hudson:hudson-remoting
includeVersion("org.eclipse.hudson", "hudson-remoting", "3.0.3")
}
}
mavenCentral()
}
Also since pom is not downloaded you would have to add hudson-remoting dependencies by hand to build.gradle. But luckily for this particular case hudson-core already contains the only dependency commons-codec:commons-codec:1.4 that hudson-remoting needs, so this is not needed.
Note: the order of repositories is important, although in that case it will work either way. If you don't want to care about the order when using repositories with filter check exclusive content filtering.

Why am I getting "could not find com.android.tools.build:gradle" error?

This is based off my last question as well.
Following this tutorial, I cloned the project into my machine and am trying to get the project to build properly.
In the process of fixing the error I got in my last question, I encountered a new error.
This is the section of the build script I am trying to fix/edit
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.3'
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
Following the instructions on how to check Gradle version, I checked mine and saw that I was running Gradle version 2.2.1. Based off that, I changed
classpath 'com.android.tools.build:gradle:1.2.3'
to
classpath 'com.android.tools.build:gradle:2.2.1'
However after changing that build script code, and attempting to rebuild my project, I get the above mentioned error(full stack trace below)
Error:Could not find com.android.tools.build:gradle:2.2.1.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
file:/C:/Users/chris/.m2/repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
file:/C:/Users/chris/.m2/repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
Required by:
:theplanethatcouldntflygood:unspecified
Does anyone know why I am getting this error or how to fix this? It doesn't make sense for me to point the Java compiler(classpath) at a Gradle Version that I am not even using.
You are confusing between android gradle plugin and gradle version.
This classpath 'com.android.tools.build:gradle:1.2.3' is a gradle plugin for Android and as of this time, 1.2.3 is the latest.
The gradle version itself is in gradle-wrapper.properties file. 2.4 is the latest version,
Per #Hamidreza's answer, check the maven and jcenter repos. Indeed jcenter (currently) has newer tools than maven.
So in the top-level build.gradle file,
change "mavenCentral" to "jcenter" like this
repositories {
//mavenCentral()
jcenter()
}
you can find last version in this address :
repo1.maven.org/maven2/com/android/tools/build/gradle
jcenter.bintray.com/com/android/tools/build/gradle
buildscript {
repositories {
maven { url "https://jcenter.bintray.com" }
maven { url "http://repo1.maven.org/maven2" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://jcenter.bintray.com" }
maven { url "http://repo1.maven.org/maven2" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I fixed this exact issue by upgrading my version of Android Studio. I was receiving an error Could not find com.android.tools.build:gradle:2.2.0, and was running a 2.1.x version of Studio at the time.
A simple upgrade to 2.2.2 immediately fixed my issue. Hope this can help somebody!
If you're behind a proxy, make sure Android Studio is set up for that. It does NOT assume system proxy settings.
My copy of Studio + Gradle wasn't set up to go through the proxy, and as a result it was giving me this error. Would've been nice to get a clear "hey buddy, I can't hit the web", but I got this error instead.

Resources