Skip to content

Commit

Permalink
Do not access 'project.zipTree' in mapping closure
Browse files Browse the repository at this point in the history
This is not supported by the Configuration Cache. Instead, we inject
an ArchiveOperations service.

Fixes #229
  • Loading branch information
jjohannes committed Dec 11, 2023
1 parent 0d1e7a8 commit 2d6f14e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/funcTest/groovy/me/champeau/jmh/ParameterSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ParameterSpec extends AbstractFuncSpec {

def "executes with configuration cache"() {
given:
usingGradleVersion(GradleVersion.version("7.6"))
usingSample("java-project")

when:
Expand Down
12 changes: 10 additions & 2 deletions src/main/groovy/me/champeau/jmh/JMHPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.file.ArchiveOperations
import org.gradle.api.file.Directory
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileCopyDetails
Expand All @@ -35,10 +36,12 @@ import org.gradle.plugins.ide.eclipse.EclipseWtpPlugin
import org.gradle.plugins.ide.idea.IdeaPlugin
import org.gradle.util.GradleVersion

import javax.inject.Inject

/**
* Configures the JMH Plugin.
*/
class JMHPlugin implements Plugin<Project> {
abstract class JMHPlugin implements Plugin<Project> {
private static GradleVersion GRADLE_MIN = GradleVersion.version('7.0')
private static boolean IS_GRADLE_MIN = GradleVersion.current() >= GRADLE_MIN

Expand All @@ -50,6 +53,9 @@ class JMHPlugin implements Plugin<Project> {
static final String JMH_TASK_COMPILE_GENERATED_CLASSES_NAME = 'jmhCompileGeneratedClasses'
static final String JHM_RUNTIME_CLASSPATH_CONFIGURATION = 'jmhRuntimeClasspath'

@Inject
protected abstract ArchiveOperations getArchives()

void apply(Project project) {
assertMinimalGradleVersion()
project.plugins.apply(JavaPlugin)
Expand Down Expand Up @@ -265,6 +271,8 @@ class JMHPlugin implements Plugin<Project> {
Provider<Directory> jmhGeneratedClassesDir,
Configuration runtimeConfiguration) {
project.tasks.register(JMH_JAR_TASK_NAME, Jar) {
def archives = archives

it.group = JMH_GROUP
it.dependsOn JMH_TASK_COMPILE_GENERATED_CLASSES_NAME
it.inputs.files project.sourceSets.jmh.output
Expand All @@ -277,7 +285,7 @@ class JMHPlugin implements Plugin<Project> {
it.collect { it.asFile }
.findAll { it.directory || it.name.toLowerCase().endsWith('.jar') }
.collect {
it.directory ? it : project.zipTree(it)
it.directory ? it : archives.zipTree(it)
} as Set
}).exclude(metaInfExcludes)
def jmhSourceSetOutput = project.sourceSets.jmh.output
Expand Down

0 comments on commit 2d6f14e

Please sign in to comment.