I'm using gradle plugin:
id 'org.springframework.boot' version '2.7.2'
And getting this. Am I missing something?
Could not resolve all files for configuration ':classpath'.
> Could not find org.springframework.boot:spring-boot-buildpack-platform:2.7.2.
Searched in the following locations:
- https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-buildpack-platform/2.7.2/spring-boot-buildpack-platform-2.7.2.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 : >
org.springframework.boot:org.springframework.boot.gradle.plugin:2.7.2 >
org.springframework.boot:spring-boot-gradle-plugin:2.7.2
> Could not find org.springframework.boot:spring-boot-loader-tools:2.7.2.
Searched in the following locations:
- https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-loader-
tools/2.7.2/spring-boot-loader-tools-2.7.2.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 : >
org.springframework.boot:org.springframework.boot.gradle.plugin:2.7.2 >
org.springframework.boot:spring-boot-gradle-plugin:2.7.2
When repository gradlePluginPortal() doesn't have it, try mavenCentral():
runtimeOnly 'org.springframework.boot:spring-boot-buildpack-platform:2.7.1'
But there no version 2.7.2 yet. Not sure if these versions would have to match, but in case of, downgrading to id 'org.springframework.boot' version '2.7.1' might be your best chance.
Just see for yourself, it's imply not there. Please don't ask me why they've not published it.
When versions can be mixed, one can use resolutionStrategy to change the version it will resolve:
In file settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
resolutionStrategy {
eachPlugin {
if (it.requested.id.getName() == 'org.springframework.boot') {
if (it.requested.id.id == 'spring-boot-buildpack-platform') {
it.useModule('org.springframework.boot:spring-boot-buildpack-platform:2.7.1')
}
println ">> ${it.target}"
} else {
println "> ${it.target}"
}
}
}
}
Either with it.useModule or it.version. println ">> ${it.target}" is just there for tesing.
Option B will work while the public API of spring-boot-buildpack-platform hasn't changed.
Related
I was using gradle 5.x until now and am trying to upgrade to 7.1.1. With this, I am running into this error -
> Could not find jp.classmethod.aws:gradle-aws-plugin:0.36.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/jp/classmethod/aws/gradle-aws-plugin/0.36/gradle-aws-plugin-0.36.pom
- https://plugins.gradle.org/m2/jp/classmethod/aws/gradle-aws-plugin/0.36/gradle-aws-plugin-0.36.pom
Required by:
project : > jp.classmethod.aws:jp.classmethod.aws.gradle.plugin:0.36
project : > jp.classmethod.aws.s3:jp.classmethod.aws.s3.gradle.plugin:0.36
In my build.gradle -
plugins {
id 'java-library'
//id 'maven' //this does not work with 7.1.1 either
id 'jp.classmethod.aws' version '0.36'
id 'jp.classmethod.aws.s3' version '0.36'
}
From the error, it is looking for the pom in -
https://repo.maven.apache.org/maven2/jp/classmethod/aws/gradle-aws-plugin/0.36/gradle-aws-plugin-0.36.pom
when actually, it is present in -
https://plugins.gradle.org/m2/jp/classmethod/aws/jp.classmethod.aws.gradle.plugin/0.36/jp.classmethod.aws.gradle.plugin-0.36.pom
I tried specifying the repository this way -
buildscript {
repositories {
mavenCentral()
//jcenter() //gradle 7.1.1 does not like this
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://plugins.gradle.org/m2/jp/classmethod/aws/jp.classmethod.aws.gradle.plugin/0.36/" }
maven { url "https://plugins.gradle.org/m2/jp/classmethod/aws/s3/jp.classmethod.aws.s3.gradle.plugin/0.36/" }
}
dependencies {
classpath "gradle.plugin.org.scoverage:gradle-scoverage:4.0.1"
classpath "jp.classmethod.aws:gradle-aws-plugin:0.36"
classpath "jp.classmethod.aws:gradle-aws-plugin:0.36"
}
}
apply plugin: "jp.classmethod.aws"
apply plugin: "jp.classmethod.aws.s3"
in which case it gives me this -
> Could not find jp.classmethod.aws:gradle-aws-plugin:0.36.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/jp/classmethod/aws/gradle-aws-plugin/0.36/gradle-aws-plugin-0.36.pom
- https://plugins.gradle.org/m2/jp/classmethod/aws/gradle-aws-plugin/0.36/gradle-aws-plugin-0.36.pom
- https://plugins.gradle.org/m2/jp/classmethod/aws/jp.classmethod.aws.gradle.plugin/0.36/jp/classmethod/aws/gradle-aws-plugin/0.36/gradle-aws-plugin-0.36.pom
- https://plugins.gradle.org/m2/jp/classmethod/aws/s3/jp.classmethod.aws.s3.gradle.plugin/0.36/jp/classmethod/aws/gradle-aws-plugin/0.36/gradle-aws-plugin-0.36.pom
Any clues how to fix this?
Thanks!!
I'm using Gradle 6.9 and here is my build.gradle file:
plugins {
id "groovy"
id "java"
}
group "com.matthiasdenu"
version "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url 'https://repo.jenkins-ci.org/releases/'
}
}
ext {
jobDslVersion = "1.77"
jenkinsVersion = "2.252"
}
sourceSets {
jobs {
groovy {
srcDirs "jobs"
compileClasspath += main.compileClasspath
}
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
dependencies {
compile("org.jenkins-ci.main:jenkins-war:${jenkinsVersion}"){
// https://github.com/sheehan/job-dsl-gradle-example/issues/87
exclude group: "org.jenkins-ci.ui", module: "bootstrap"
}
}
test {
useJUnitPlatform()
}
This is the error message I'm getting:
Execution failed for task ':compileTestGroovy'.
> Could not resolve all files for configuration ':testCompileClasspath'.
> Could not find org.connectbot.jbcrypt:jbcrypt:1.0.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/connectbot/jbcrypt/jbcrypt/1.0.0/jbcrypt-1.0.0.pom
- https://repo.jenkins-ci.org/releases/org/connectbot/jbcrypt/jbcrypt/1.0.0/jbcrypt-1.0.0.pom
Required by:
project : > org.jenkins-ci.main:jenkins-war:2.252 > org.jenkins-ci.main:jenkins-core:2.252
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
What's odd is that the 1.0.0 artifact doesn't show up at https://repo.maven.apache.org/maven2/org/connectbot/jbcrypt/. I also noticed that the urls don't quite match either. Like if I try to get v1.0.1 it doesn't resolve either because it expects an extra "jbcrypt" for the group name.
I have this problem even when using the latest jenkins-war release (2.304).
What's going on?
You have to add the Jenkins public repository to your configuration. It contains all libraries available in the releases repository and all required dependencies.
The file exists: https://repo.jenkins-ci.org/public/org/connectbot/jbcrypt/jbcrypt/1.0.0/jbcrypt-1.0.0.jar
repositories {
mavenCentral()
maven {
url 'https://repo.jenkins-ci.org/public/'
}
}
I have a build.gradle with
plugins {
id {some plugin for all projects}
id "com.diffplug.spotless" version "5.1.1"
}
AND THEN I have an allprojects {} section that defines ONE apply plugin: 'jacoco' and a subprojects {} section that declares apply plugin: 'java' with a few others
Immediately adding spotless messed with stuff and errors out that it cannot find the java plugin so then I modify ALL plugins to be in the plugins section like so
plugins {
id "java"
id "checkstyle"
id "eclipse"
id "idea"
id "jacoco"
id "com.diffplug.spotless" version "5.1.1"
id "com.dorongold.task-tree" version "1.5" //This prints out a task tree (pretty print)
}
This then results in this error
Could not find method testCompile() for arguments [junit:junit:4.11] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
So for some reason the java plugin is lost. I can't figure out the right combination here to migrate everything to this new plugins section format.
How do I do that? I randomly tried putting a plugins section in allprojects and subprojects but that results in this new error
Could not find method plugins() for arguments [build_d8c2jgy4ua1m0vkv9kmvgefmc$_run_closure2$_closure5#62337fda] on root project 'providersvc-all' of type org.gradle.api.Project
How does this new plugins section work? I can't seem to migrate without it breaking everything. I just want java plugin, testCompile, and spotless to play nicely together right now
EDIT(forgot to attach the full trimmed down file that does not work):
plugins {
id "java"
id "com.diffplug.spotless" version "5.1.1"
}
ext {
//dependency versions every project usees so we version in one location all jars(less jar hell this way)
deps = [
'junit': 'junit:junit:4.11'
]
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
//webpieces VERSIONED snapshots so you can lock on a snapshot
url "https://dl.bintray.com/deanhiller/maven"
}
//For testing locally
maven {
url uri('/tmp/myRepo/')
}
}
}
subprojects {
dependencies {
testCompile deps['junit']
}
}
thanks,
Dean
You are only applying the plugins to the root project - not the sub-projects. However, if you like to configure plugins through the subprojects configuration, you have to use the apply plugin syntax. But you don't have to use the old buildscript block for configuring the classpath and repositories if you a combination of the two.
Here is an example. I am assuming the root project is not a Java project. I have also removed your comments and inserted mine instead for the sole reason to make them easier to spot.
plugins {
id "com.diffplug.spotless" version "5.1.1" apply false // <-- Set "apply false" here
// This makes it configure which version to use on the classpath for the entire build, but without applying it.
// Notice that the Java plugin is not specified here anymore.
// This is because it is a core plugin so you can't set the version (and I am assuming you don't want it on in the root project).
}
ext {
deps = [
'junit': 'junit:junit:4.11'
]
}
allprojects {
repositories {
jcenter()
mavenCentral() // <-- You can remove this if you want as it is already present as a proxy in jcenter().
maven {
url "https://dl.bintray.com/deanhiller/maven"
}
maven {
url uri('/tmp/myRepo/')
}
}
}
subprojects {
// Here are the two plugins
apply plugin: "java"
apply plugin: "com.diffplug.spotless"
dependencies {
testImplementation deps['junit'] // <-- testCompile renamed to testImplementation as the former has been deprecated for a long time
}
}
I need to change a multi-project build to a single-project build, as there is and only ever will be one project in this repo. Currently, in settings.gradle, I have a custom plugin repo that currently uses a pluginManagement block with resolutionStrategy and my list of repo's:
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == 'com.meanwhileinhell.plugin') {
useModule('com.meanwhileinhell:gradle-plugin:1.0.0-SNAPSHOT')
}
}
}
repositories {
mavenLocal()
maven { url "https://repo.spring.io/milestone" }
maven { url "https://plugins.gradle.org/m2/" }
// Meanwhileinhell repo
maven {
url "s3://mvn.meanwhileinhell.com/releases"
credentials(AwsCredentials) {
accessKey s3_access_key
secretKey s3_access_secret
}
}
}
plugins {
...
...
}
}
However, deleting settings.gradle and moving this block into my build.gradle.kts (Kotlin DSL) seems to do nothing. I've tried wrapping in a
configurations {
all {
resolutionStrategy {
eachPlugin {
...
}
}
}
}
and also
settings {
pluginManagement {
resolutionStrategy {
eachPlugin {
...
}
}
}
}
I found a SO answer that used settingsEvaluated in order to get the settings object, but again this was a no go.
Currently my build.gradle.kts looks like this, without pulling any plugin in from my repo:
val springBootVersion: String by project
group = "com.meanwhileinhell.myapp"
version = "$version"
repositories {
mavenCentral()
mavenLocal()
maven ("https://repo.spring.io/snapshot")
maven ("https://repo.spring.io/milestone")
maven ("https://plugins.gradle.org/m2/")
maven {
url = uri("s3://mvn.meanwhileinhell.com/releases")
credentials(AwsCredentials::class) {
accessKey = (project.property("s3_access_key") as String)
secretKey = (project.property("s3_access_secret") as String)
}
}
}
plugins {
base
eclipse
idea
java
id("io.spring.dependency-management") version "1.0.9.RELEASE"
// Load but don't apply to root project
id("org.springframework.boot") version "1.5.14.RELEASE" apply false
}
dependencies {
...
}
Whenever I try to add a plugin id like id("com.meanwhileinhell.plugin.hell2java") version "1.0.0-SNAPSHOT" I get an error that looks like it isn't even looking in my S3 location:
* What went wrong:
Plugin [id: 'com.meanwhileinhell.plugin.hell2java', version: '1.0.0-SNAPSHOT'] 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 'com.meanwhileinhell.plugin.hell2java:com.meanwhileinhell.plugin.hell2java.gradle.plugin:1.0.0-SNAPSHOT')
Searched in the following repositories:
Gradle Central Plugin Repository
Any help on this would be appreciated!
EDIT !!!! -----------------------
I've just found this in the Gradle docs:
https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_management
The pluginManagement {} block may only appear in either the settings.gradle file....
Looks like I'm going down the wrong way entirely, so will look into the initialisation script route.
I think you may have missed something about the file structure.
In the Groovy DSL, you have the following files:
build.gradle
settings.gradle
init.gradle
In the Kotlin DSL, you have the same files but with the .kts extension:
build.gradle.kts
settings.gradle.kts
init.gradle.kts
The Kotlin DSL doesn't differ to the Groovy DSL in where to put things. pluginManagement need to go in to the settings file, so for Kotlin that would be settings.gradle.kts. If you are in doubt, look at the documentation. For almost all code examples, you can switch between Groovy and Kotlin DSL to see how to do it (and which files they are supposed go to into).
How to apply a specific plugin version using newer Gradle syntax? I would like to do something like this but this gives an error of unknown property 'version':
apply plugin: 'com.bmuschko.docker-remote-api', version: '2.0.3'
The new plugin syntax can be seen on the Gradle Plugins Repository page for the plugin you wish to apply: https://plugins.gradle.org/plugin/com.bmuschko.docker-remote-api
Using the plugins DSL:
plugins {
id "com.bmuschko.docker-remote-api" version "6.1.3"
}
Using legacy plugin application:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.bmuschko:gradle-docker-plugin:6.1.3"
}
}
apply plugin: "com.bmuschko.docker-remote-api"
In your build.gradle file, apply the plugin with a plugins block near the top of your script:
plugins {
id "com.bmuschko.docker-remote-api" version "2.0.3"
}
The syntax you have there is not new, it the legacy plugin application
To specify the version for the legacy way, you need to use the buildscript { } block:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.bmuschko:gradle-docker-plugin:2.0.3"
}
}
apply plugin: "com.bmuschko.docker-remote-api"