Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin application fails on Gradle 8.0 #131

Closed
catostrophe opened this issue Feb 13, 2023 · 10 comments · Fixed by #132
Closed

Plugin application fails on Gradle 8.0 #131

catostrophe opened this issue Feb 13, 2023 · 10 comments · Fixed by #132

Comments

@catostrophe
Copy link
Contributor

This fails since AbstractArchiveTask#setClassifier is dropped in Gradle 8.0.

@tomasbjerre
Copy link

I switched to JVM Test Suite (as suggested in #132) and ended up with:

testing {
   suites {
      test {
         useJUnitJupiter()
      }
      integTest(JvmTestSuite) {
         sources.java.srcDirs = ['src/integtest/java']
         sources.resources.srcDirs = ['src/integtest/resources']
         dependencies {
            implementation project()
            implementation sourceSets.test.output
         }
         targets {
            all {
               testTask.configure {
                  shouldRunAfter(test)
               }
            }
         }
      }
   }
}

configurations {
   integTestImplementation.extendsFrom testImplementation
}

tasks.named('check') { 
   dependsOn(testing.suites.integTest)
}

tasks.named("sourcesJar") {
   dependsOn("compileJava")
   dependsOn("compileTestJava")
   dependsOn("compileIntegTestJava")
}
tasks.named("javadoc") {
   dependsOn("compileJava")
   dependsOn("compileTestJava")
   dependsOn("compileIntegTestJava")
}

@jimshowalter
Copy link

The fix is to replace classifier with archiveClassifier, at least according to https://discuss.gradle.org/t/publishing-jars-with-classifiers-after-v5-0/30144

@jimshowalter
Copy link

Here's the bug:

// Classifier is deprecated, but the new archiveClassifier was added only in Gradle 5.1
// For compatibility we will still use the old one
@Suppress("DEPRECATION")
task.classifier = testSet.classifier

@jimshowalter
Copy link

So either gradle-testsets-plugin can't ever be used with Gradle 8.x or newer, or has to be non-backward-compatible with Gradle earlier than 5.1. It's not possible to have it both ways (unless the repo is forked).

@jimshowalter
Copy link

@tkrullmann @cpiotr

@rkrisztian
Copy link

rkrisztian commented May 5, 2023

@tomasbjerre thanks for your example code, the JVM Test Suite seems indeed a more future-proof solution for what we so far have set up using the test sets plugin. However, I'd avoid setting these:

         // Breaks conventions :(
         sources.java.srcDirs = ['src/integtest/java']
         sources.resources.srcDirs = ['src/integtest/resources']

If you just remove those lines and let them get derived from convention, then you end up with the folder src/integTest/. It's not bad IMO, using uppercase letters in paths. Several paths in Gradle are named after the task name, e.g., HTML reports. So you will also be consistent just by letting the conventions do their job, leading to easier-to-use builds.

@jimshowalter
Copy link

This bug can probably be fixed via reflection.

First use reflection try to get the task.archiveClassifier declared field.

If present, use reflection to set the field.

If not present, use reflection to get the task.classifier field, make it accessible, and set it.

@dhakehurst
Copy link

This bug is also a problem for me...I need to use gradle 8 (actually 8.1.1),
when will there be a new release compatible ?

@rkrisztian
Copy link

@dhakehurst, the JVM Test Suite feature can pretty much replace what this plugin does, see conversation above.

@rkrisztian
Copy link

It looks like Gradle's built-in solution can still hurt us if we want back the following behavior configured for all subprojects without code duplication:

A dependency configuration named integrationTestImplementation, which extends from "testImplementation";

In detail, see gradle/gradle#19870 (comment) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants