Gradle 6.5 issue with plugin “com.gradle:gradle-enterprise-gradle-plugin:3.3.3 - gradle

I am really annoyed with com.gradle.enterprise plugin as the id and groupid different
I finally tried to redirect using
pluginManagement {
repositories {
maven { url "https://artifactory.XXX/artifactory/public/" }
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.gradle.enterprise") {
useModule("com.gradle:gradle-enterprise-gradle-plugin:3.3.3")
}
}
}
}
plugins {
id "com.gradle.enterprise" version "3.3.3"
}
Now all I am getting the error is
Plugin not found in org.gradle instead of searching in com.gradle
Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: ‘com.gradle.enterprise’, version: ‘3.3.3’, artifact: ‘com.gradle:gradle-enterprise-gradle-plugin:3.3.3’] 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.gradle:gradle-enterprise-gradle-plugin:3.3.3’)

Related

Gradle 7.1.1 Could not find jp.classmethod.aws:gradle-aws-plugin

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!!

Gradle single-project pluginManagement block not working (Kotlin DSL)

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).

Add specific plugin version in Gradle using 'Apply'

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"

Gradle plugin with custom group id

Gradle 6.1
I am having difficulties to use the new plugin configuration mode in Gradle with a custom plugin coming from a custom repository.
buildscript {
repositories {
maven {
url = uri("https://custom")
}
mavenCentral()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
}
plugins {
java
idea
id("com.custom.gradle.plugin.myplugin") version "1.1.0"
}
I get this error:
Plugin [id: 'com.custom.gradle.plugin.myplugin', version: '1.1.0'] 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.custom.gradle.plugin.myplugin:com.custom.gradle.plugin.myplugin:1.1.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Gradle will use the plugin id as its group id.
It works if I use the old ways:
buildscript {
repositories {
maven {
url = uri("https://custom")
}
mavenCentral()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.custom:com.custom.gradle.plugin.myplugin:1.1.0")
}
}
apply(plugin = "com.custom.gradle.plugin.myplugin")
Is there a way to specify the group id with the 'id' command? Or am I breaking the plugin definition's contract with that old plugin?
In order to use the newer/preferred plugins { } DSL, the custom plugin must publish a plugin marker artifact.
If the custom plugin is able to be modified, then I suggest updating to make use of the Java Gradle Plugin Development plugin which will create the marker for you.
If the plugin is not able to be updated, then you can still use the plugins { } block, but you'll need to manually resolve the plugin:
In the main build.gradle:
plugins {
id("com.custom.gradle.plugin.myplugin") version "1.1.0"
}
Then resolve the plugin manually in settings.gradle:
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.custom.gradle.plugin.myplugin") {
useModule("com.custom:com.custom.gradle.plugin.myplugin:${requested.version}")
}
}
}
}
See Plugin Resolution Rules
for more details.

Gradle 5: Failed to apply plugin [id 'aspectj']

I am trying to run a build.gradle file that looks like this and which returns an error on line apply plugin: 'aspectj'
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/libs-snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/libs-milestone" }
maven { url "https://maven.eveoh.nl/content/repositories/releases" }
}
dependencies {
classpath "nl.eveoh:gradle-aspectj:2.0"
}
}
apply plugin: 'aspectj'
jar {
manifest {
attributes(
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch5.AspectJDemo",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
}
The error message is as follows:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/Spring/pro-spring-5-master/chapter05/aspectj-aspects/build.gradle' line: 17
* What went wrong:
A problem occurred evaluating project ':chapter05:aspectj-aspects'.
> Failed to apply plugin [id 'aspectj']
> Could not find method deleteAllActions() for arguments [] on task ':chapter05:aspectj-aspects:compileJava' of type org.gradle.api.tasks.compile.JavaCompile.
What am I doing wrong here?
AspectJ is not compatible with Gradle 5.0 - see issues #7861 and #8063.
The most easy might be to replace the plugin; eg. with io.freefair.aspectj.post-compile-weaving, because aspectj.gradle had been last updated 2 years ago (it seems abandoned).
I have fixed the issue and published a new version to jcenter. Find it here: https://bintray.com/zebalu/releases/gradle-aspectj
currently you need this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.github.zebalu:gradle-aspectj:2.3.3'
}
}
apply plugin: 'gradle-aspectj'
// rest of your code

Resources