Skip to content

Commit

Permalink
Merge pull request #261 from jjohannes/fix-229
Browse files Browse the repository at this point in the history
Do not access 'project.zipTree' in mapping closure
  • Loading branch information
melix committed Dec 13, 2023
2 parents 0d1e7a8 + b1356df commit 2c29b07
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class AbstractFuncSpec extends Specification {

protected static final List<GradleVersion> TESTED_GRADLE_VERSIONS = [
GradleVersion.version('7.0'),
GradleVersion.version('8.0'),
GradleVersion.current()
]

Expand Down
6 changes: 3 additions & 3 deletions src/funcTest/groovy/me/champeau/jmh/ParameterSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package me.champeau.jmh

import org.gradle.util.GradleVersion

import spock.lang.Unroll

import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
Expand All @@ -39,15 +39,15 @@ class ParameterSpec extends AbstractFuncSpec {

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

when:
def result = build("jmhJar", "--configuration-cache")

then:
result.task(":jmhJar").outcome == SUCCESS
result.output.contains("Calculating task graph as no configuration cache is available for tasks: jmhJar")
result.output.contains("Calculating task graph as no configuration cache is available for tasks: jmhJar") ||
result.output.contains("Calculating task graph as no cached configuration is available for tasks: jmhJar")

when:
result = build("jmhJar", "--configuration-cache")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package me.champeau.jmh

import org.gradle.testkit.runner.TaskOutcome

import org.gradle.util.GradleVersion
import spock.lang.Unroll

Expand All @@ -32,7 +32,7 @@ class UnsupportedGradleVersionSpec extends AbstractFuncSpec {
def result = buildAndFail("jmh")
then:
result.output.contains('Please upgrade Gradle or use an older version of the JMH Gradle plugin.')
result.output.contains('Please upgrade Gradle or use an older version of the JMH Gradle plugin.')
where:
gradleVersion << GradleVersion.version('6.9')
Expand Down
11 changes: 10 additions & 1 deletion 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,6 +36,8 @@ 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.
*/
Expand Down Expand Up @@ -265,6 +268,7 @@ class JMHPlugin implements Plugin<Project> {
Provider<Directory> jmhGeneratedClassesDir,
Configuration runtimeConfiguration) {
project.tasks.register(JMH_JAR_TASK_NAME, Jar) {
def archives = project.objects.newInstance(ServiceInjection).archiveOperations
it.group = JMH_GROUP
it.dependsOn JMH_TASK_COMPILE_GENERATED_CLASSES_NAME
it.inputs.files project.sourceSets.jmh.output
Expand All @@ -277,7 +281,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 Expand Up @@ -329,4 +333,9 @@ class JMHPlugin implements Plugin<Project> {
}
newConfig
}

interface ServiceInjection {
@Inject
ArchiveOperations getArchiveOperations()
}
}

0 comments on commit 2c29b07

Please sign in to comment.