Getting error building a gradle project: An exception occurred applying plugin request [id: 'org.jetbrains.intellij', version: '1.5.2'] - gradle

I am getting the next error message when I build a gradle project (gradle build):
An exception occurred applying plugin request [id: 'org.jetbrains.intellij', version: '1.5.2']
> Failed to apply plugin [id 'org.jetbrains.intellij']
> Could not create an instance of type org.jetbrains.intellij.utils.ArchiveUtils.
> Could not generate a decorated class for type ArchiveUtils.
> org/gradle/api/file/ArchiveOperations
My plugin section looks like this:
plugins {
id 'org.jetbrains.intellij' version '1.5.2'
id 'jacoco'
id 'groovy'
id 'signing'
id 'maven-publish'
}
I am using java version 11 and gradle 7.6. Not sure at this moment what is happening. I didn't find enough info regarding this error.
Any ideas?
Thanks!

Related

Cannot find Plugin [id: 'com.github.johnrengelman.shadow', version: '5.2.0']

I'm currently trying to create a simple discord bot. I finished the code and I'm trying to export it through shadow--> shadowJar. I keep getting this error message:
Plugin [id: 'com.github.johnrengelman.shadow', version: '5.2.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.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:5.2.0')
Searched in the following repositories:
Gradle Central Plugin Repository
I've tried to look up how to fix this, being pretty unsuccessful. I'm very new to this, only having experience with simple Java, like multi-dimensional arrays, classes, objects, etc.
Please help!
Here's my build.gradle:
plugins {
id 'java'
id 'application'
id "com.github.johnrengelman.shadow" version "5.2.0"
}
mainClassName = "Main"
group 'com.mywebsite'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'net.dv8tion:JDA:3.5.0_329'
}
At the time of writing this answer, the shadow plugin's latest version is 2.0.3.
So I have no idea where you sourced that 5.2.0 from but this is the issue: there is no shadow plugin version 5.2.0 out there.

Gradle 6.1 isn't finding the com.moowork.gulp plugin

Upgrading from Gradle 4.0 to 6.1, the com.moowork.glup plugin seems to have vanished. Yet, the https://plugins.gradle.org/plugin/com.moowork.gulp page show that the plugin does exist. The sample code works with the com.moowork.gulp line commented out.
plugins {
id 'java'
id 'maven'
id "com.moowork.gulp" version "1.3.0"
id "nebula.ospackage" version "8.0.3"
}
task testAgain {
println 'Configuration stage'
doLast {
println 'Execution stage'
}
}
Once the offending line is uncommented, the Gradle example fails.
$ ./gradlew -q testAgain
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'example'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.moowork.gradle:gradle-node-plugin:1.3.0.
Searched in the following locations:
- https://plugins.gradle.org/m2/com/moowork/gradle/gradle-node-plugin/1.3.0/gradle-node-plugin-1.3.0.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 : > com.moowork.gulp:com.moowork.gulp.gradle.plugin:1.3.0
[...]
BUILD FAILED in 1s
What am I missing?

Gradle does not see a plugin that is on the plugin portal

Gradle 4.6 here. Trying to use markdown-gradle-plugin to convert markdown files into HTML as part of my build. My build.gradle specifies:
plugins {
id 'com.github.johnrengelman.shadow' version '4.0.4'
id 'java'
id 'edu.sc.seis.launch4j' version '2.4.6'
id 'org.kordamp.gradle.markdown' version '2.0.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
compile(
'ch.qos.logback:logback-classic:1.2.3'
... (all of my dependencies here)
)
}
... rest of my build.gradle here
When I run:
./gradlew clean markdownToHtml
I get:
$ ./gradlew clean markdownToHtml
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/myuser/workspace/myapp/build.gradle' line: 14
* What went wrong:
An exception occurred applying plugin request [id: 'org.kordamp.gradle.markdown', version: '2.0.0']
> Failed to apply plugin [id 'org.kordamp.gradle.markdown']
> Could not find method register() for arguments [markdownToHtml, class org.kordamp.gradle.plugin.markdown.tasks.MarkdownToHtmlTask, org.kordamp.gradle.plugin.markdown.MarkdownPlugin$1#3b46a8ba] on task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.
* 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
I can verify that I do see the 2.0.0 version of the plugin on the Gradle plugin portal.
Can anybody spot where I'm going awry?
According to the kordmap plugins website:
Java 8 and Gradle 5 are the minimum requirements to use any of these
plugins.
So your version of gradle needs an upgrade.
The error is coming from when the plugin attempts to use TaskContainer::register, which was introduced in gradle 4.9, so you might be safe to upgrade to version 4.9, but I'd suggest going with what the website says and bumping it to version 5.

java.lang.NoSuchFieldError: INSTANCE error during gradle artifactoryPublish task

We're trying to migrate our project configured with gradle 4.0 into gradle 5.6 (latest). Looks like there's a dependency issue with httpclient (apache) component that generate this exception during the Publish of the war package.
This is a gradle project, root (container) project has included a war plugin for packaging, jfrog artifactory 4.9.8 for publishing, all the subprojects are java projects with their dependency list provided (included httpclient 4.5.9 and httpcore 4.4.11).
-- root
plugins {
id 'war'
id 'maven-publish'
id 'org.sonarqube' version '2.7'
id 'net.researchgate.release' version '2.6.0'
id 'com.github.spotbugs' version '2.0.0' apply false
id 'com.jfrog.artifactory' version '4.9.8'
}
-- subprojects
dependencies {
..
compile 'org.apache.httpcomponents:httpclient:4.5.9'
..
configurations.all {
force 'org.apache.httpcomponents:httpcore:4.4.11'
force 'org.apache.httpcomponents:httpclient:4.5.9'
}
}
./gradlew artifactoryPublish
What went wrong:
Execution failed for task ':artifactoryDeploy'.
INSTANCE
Caused by: java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:109)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:116)
at org.jfrog.build.client.PreemptiveHttpClient.<init>(PreemptiveHttpClient.java:57)
at org.jfrog.build.client.ArtifactoryHttpClient.getHttpClient(ArtifactoryHttpClient.java:145)
at org.jfrog.build.client.ArtifactoryHttpClient.getHttpClient(ArtifactoryHttpClient.java:140)
at org.jfrog.build.client.ArtifactoryHttpClient.executeGetRequest(ArtifactoryHttpClient.java:184)
at org.jfrog.build.client.ArtifactoryHttpClient.getVersion(ArtifactoryHttpClient.java:154)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBaseClient.getArtifactoryVersion(ArtifactoryBaseClient.java:109)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.tryChecksumDeploy(ArtifactoryBuildInfoClient.java:705)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.uploadFile(ArtifactoryBuildInfoClient.java:664)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.doDeployArtifact(ArtifactoryBuildInfoClient.java:367)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:355)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:340)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.deployArtifacts(DeployTask.java:262)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.prepareAndDeploy(DeployTask.java:113)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.collectProjectBuildInfo(DeployTask.java:50)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.taskAction(DeployTask.java:44)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)

Write a Gradle Plugin that reacts to multiple plugins

I am trying to write a new Gradle plugin which requires the application of two plugins: either java or java-library, or maven-publish. I am writing the plugin in Kotlin.
I can easily, following the Gradle guide, make the plugin react to a single plugin application:
project.plugins.withType(MavenPublishPlugin::class.java) {
// My stuff
}
But I can't do the same for requiring two plugin applications:
project.plugins.withType(JavaPlugin::class.java) {
project.plugins.withType(MavenPublishPlugin::class.java) {
// My stuff
}
}
In the second case, launching with:
Case 1: as expected
plugins {
id("java")
id("maven-publish")
id("org.danilopianini.publish-on-central")
}
runs the plugin as expected
Case 2: non applied, as expected
using:
plugins {
id("java")
id("org.danilopianini.publish-on-central")
}
does not apply the plugin, as expected
Case 3: applied, it should have not been
but, finally:
plugins {
id("maven-publish")
id("org.danilopianini.publish-on-central")
}
tries to apply the plugin and fails with:
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/junit876726632157783854/build.gradle.kts' line: 1
* What went wrong:
An exception occurred applying plugin request [id: 'org.danilopianini.publish-on-central']
> Failed to apply plugin [id 'org.danilopianini.publish-on-central']
> SoftwareComponentInternal with name 'java' not found.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'org.danilopianini.publish-on-central']
[cut]
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'org.danilopianini.publish-on-central']
... 128 more
Caused by: org.gradle.api.UnknownDomainObjectException: SoftwareComponentInternal with name 'java' not found.
at org.gradle.api.internal.DefaultNamedDomainObjectCollection.createNotFoundException(DefaultNamedDomainObjectCollection.java:489)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:323)
Which looks to me as an attempt to apply the plugin regardless the fact that the Java plugin was not applied.
Do you know any way to configure a plugin to react to multiple plugin applications?

Resources