Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,96 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationTestKitSpec {
git.add(patterns: ['build.gradle', '.gitignore'] as Set)
}

def 'configuration cache is reused on second build'() {
when:
def firstRun = runTasks('build')

then:
firstRun.output.contains('Configuration cache entry stored')

when:
def secondRun = runTasks('build')

then:
secondRun.output.contains('Reusing configuration cache')
}

def 'configuration cache is reused for devSnapshot'() {
when:
def firstRun = runTasks('devSnapshot')

then:
firstRun.output.contains('Configuration cache entry stored')

when:
def secondRun = runTasks('devSnapshot')

then:
secondRun.output.contains('Reusing configuration cache')
}

def 'configuration cache entry is stored for candidate on consecutive runs'() {
when:
def firstRun = runTasks('candidate')

then:
firstRun.output.contains('Configuration cache entry stored')

when:
def secondRun = runTasks('candidate')

then:
secondRun.output.contains('configuration cache cannot be reused because a build logic input of type \'DescribeHeadWithTag\' has changed')
secondRun.output.contains('Configuration cache entry stored')
}

def 'configuration cache entry is stored for final on consecutive runs'() {
when:
def firstRun = runTasks('final')

then:
firstRun.output.contains('Configuration cache entry stored')

when:
def secondRun = runTasks('final')

then:
secondRun.output.contains('configuration cache cannot be reused because a build logic input of type \'DescribeHeadWithTagWithExclude\' has changed')
secondRun.output.contains('Configuration cache entry stored')
}

def 'configuration cache is reused for useLastTag with final'() {
git.tag.add(name: 'v42.5.3')

when:
def firstRun = runTasks('final', '-Prelease.useLastTag=true')

then:
firstRun.output.contains('Configuration cache entry stored')

when:
def secondRun = runTasks('final', '-Prelease.useLastTag=true')

then:
secondRun.output.contains('Reusing configuration cache')
}

def 'configuration cache is reused for useLastTag with candidate'() {
git.tag.add(name: 'v3.1.2-rc.1')

when:
def firstRun = runTasks('candidate', '-Prelease.useLastTag=true')

then:
firstRun.output.contains('Configuration cache entry stored')

when:
def secondRun = runTasks('candidate', '-Prelease.useLastTag=true')

then:
secondRun.output.contains('Reusing configuration cache')
}

def 'build defaults to dev version string'() {
when:
def version = inferredVersionForTask('build')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand All @@ -42,6 +43,7 @@ import javax.inject.Inject
abstract class ReleasePluginExtension {
private static final Logger logger = LoggerFactory.getLogger(ReleasePluginExtension)
protected final Project project
private final ProviderFactory providerFactory
private final Map<String, VersionStrategy> versionStrategies = [:]

/**
Expand Down Expand Up @@ -71,6 +73,7 @@ abstract class ReleasePluginExtension {
ReleasePluginExtension(Project project) {
File gitRoot = project.hasProperty('git.root') ? project.file(project.property('git.root')) : project.rootProject.projectDir
this.project = project
this.providerFactory = project.getProviders()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ProviderFactory should be passed in via the constructor, and used for the gitRoot gradle property as well

this.gitBuildService = project.getGradle().getSharedServices().registerIfAbsent("gitBuildService", GitBuildService.class, spec -> {
spec.getParameters().getGitRootDir().set(gitRoot)
}).get()
Expand Down Expand Up @@ -107,7 +110,7 @@ abstract class ReleasePluginExtension {
private final Provider<ReleaseVersion> inferredVersionProvider

DelayedVersion() {
this.inferredVersionProvider = project.provider { -> infer() }
this.inferredVersionProvider = providerFactory.provider { -> infer() }
}

@CompileDynamic
Expand Down
Loading