bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
527 stars 305 forks source link

gradle plugin version 6.2.0 not working with Gradle 7.4.2 due to missing property COMPILE_CONFIGURATION_NAME #5230

Closed SingingBush closed 2 years ago

SingingBush commented 2 years ago
An exception occurred applying plugin request [id: 'biz.aQute.bnd.builder', version: '6.2.0']
> Failed to apply plugin 'org.gradle.java'.
   > No such property: COMPILE_CONFIGURATION_NAME for class: org.gradle.api.plugins.JavaPlugin

* 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: 'biz.aQute.bnd.builder', version: '6.2.0']
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.exceptionOccurred(DefaultPluginRequestApplicator.java:223)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:205)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyLegacyPlugin(DefaultPluginRequestApplicator.java:158)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.access$300(DefaultPluginRequestApplicator.java:61)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$1$1.lambda$addLegacy$0(DefaultPluginRequestApplicator.java:114)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$applyPlugins$0(DefaultPluginRequestApplicator.java:143)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:143)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:117)
    at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
bjhargrave commented 2 years ago

Can you please provide a small github repo which demonstrates the problem?

The Bnd Gradle plugin source code does not reference COMPILE_CONFIGURATION_NAME anywhere. And the provided stacktrace does not reference any Bnd Gradle plugin classes.

The referenced error message says the error is in applying the org.gradle.java plugin.

> Failed to apply plugin 'org.gradle.java'.
   > No such property: COMPILE_CONFIGURATION_NAME for class: org.gradle.api.plugins.JavaPlugin

The Bnd Gradle plugin does apply the java plugin:

        project.getPluginManager()
            .apply("java");

The Gradle java plugin used to have a "compile" configuration but it has been deprecated and replaced. So perhaps you have some strange gradle setup.

SingingBush commented 2 years ago

Ah yes, sorry I did not notice the reference to java plugin. I have seen similar reports of this problem for other projects updating to Gradle 7.

I was on a fork of ical4j at the time that I am trying to update to Gradle 7 so that I can target JDK 17. I've pushed a branch for you: https://github.com/SingingBush/ical4j/tree/bnd_problem and the error can be seen here: https://github.com/SingingBush/ical4j/runs/6189652960?check_suite_focus=true

bjhargrave commented 2 years ago

Your build.gradle file had an awkward mix of the use of the plugins section and apply plugin: which probably was causing the issue. The plugin versions were also quite old. The following changes get your build working and show no issue in the Bnd Gradle plugin.

diff --git a/build.gradle b/build.gradle
index afcfa19d..fe161e92 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,21 +10,20 @@ buildscript {
 }

 plugins {
-    id 'pl.allegro.tech.build.axion-release' version '1.13.3'
-    id "nebula.provided-base" version "3.0.3"
-    id "net.ltgt.errorprone" version "1.2.1" apply false
+    id 'java'
+    id 'java-library'
+    id 'groovy'
+    id 'maven-publish'
+    id 'jacoco'
+    id 'signing'
+    id "pl.allegro.tech.build.axion-release" version "1.13.6"
+    id "nebula.provided-base" version "7.0.0"
+    id "nebula.optional-base" version "7.0.0"
+    id "com.palantir.revapi" version "1.7.0"
+    id "net.ltgt.errorprone" version "2.0.2" apply false
     id "biz.aQute.bnd.builder" version "$bndVersion"
 }

-apply plugin: 'java'
-apply plugin: 'java-library'
-apply plugin: 'groovy'
-apply plugin: 'maven-publish'
-apply plugin: 'jacoco'
-apply plugin: 'signing'
-apply plugin: 'pl.allegro.tech.build.axion-release'
-apply plugin: 'nebula.optional-base'
-apply plugin: 'com.palantir.revapi'
 apply from: 'gradle/dist.gradle'

 sourceCompatibility = 1.8
@@ -64,7 +63,7 @@ dependencies {

     compileOnly "biz.aQute.bnd:biz.aQute.bndlib:$bndVersion"

-    testCompile "org.codehaus.groovy:groovy:$groovyVersion",
+    testCompileOnly "org.codehaus.groovy:groovy:$groovyVersion",
             "org.slf4j:slf4j-log4j12:$slf4jVersion",
             "org.apache.logging.log4j:log4j:$log4jVersion",
             "org.ccil.cowan.tagsoup:tagsoup:$tagsoupVersion",
SingingBush commented 2 years ago

Thanks, I really appreciate your help on this. I had to fix some tests but now can build will JDK 8 through to 18