diff --git a/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePlugin.groovy b/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePlugin.groovy index ae72dab..3cf53a6 100644 --- a/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePlugin.groovy +++ b/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePlugin.groovy @@ -29,7 +29,7 @@ class SemanticReleasePlugin implements Plugin { ReleasePluginExtension releaseExtension = extensions.findByType(ReleasePluginExtension) tasks.release.doLast { if (project.version.inferredVersion.createTag) { - semanticReleaseExtension.changeLogService.createGitHubVersion(project.version.inferredVersion) + semanticReleaseExtension.changeLog.createGitHubVersion(project.version.inferredVersion) } } releaseExtension.with { diff --git a/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginExtension.groovy b/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginExtension.groovy index 181a15c..479ec3f 100644 --- a/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginExtension.groovy +++ b/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginExtension.groovy @@ -29,9 +29,9 @@ import javax.inject.Inject class SemanticReleasePluginExtension { final Project project - final SemanticReleaseChangeLogService changeLogService - final SemanticReleaseCheckBranch onReleaseBranch - final SemanticReleaseAppendBranchNameStrategy appendBranchName + final SemanticReleaseChangeLogService changeLog + final SemanticReleaseCheckBranch releaseBranches + final SemanticReleaseAppendBranchNameStrategy branchNames final SemanticReleaseNormalStrategy semanticStrategy final SemanticReleaseStrategy releaseStrategy final SemanticReleaseStrategy snapshotStrategy @@ -39,10 +39,10 @@ class SemanticReleasePluginExtension { @Inject SemanticReleasePluginExtension(Project project) { this.project = project - changeLogService = new SemanticReleaseChangeLogService(project.grgit, project.release.tagStrategy) - onReleaseBranch = new SemanticReleaseCheckBranch() - appendBranchName = new SemanticReleaseAppendBranchNameStrategy(onReleaseBranch) - semanticStrategy = new SemanticReleaseNormalStrategy(project.grgit, changeLogService) + changeLog = new SemanticReleaseChangeLogService(project.grgit, project.release.tagStrategy) + releaseBranches = new SemanticReleaseCheckBranch() + branchNames = new SemanticReleaseAppendBranchNameStrategy(releaseBranches) + semanticStrategy = new SemanticReleaseNormalStrategy(project.grgit, changeLog) releaseStrategy = new SemanticReleaseStrategy( initialStateService: new SemanticReleaseInitialStateService(project.grgit), normalStrategy: semanticStrategy, @@ -52,7 +52,7 @@ class SemanticReleasePluginExtension { snapshotStrategy = releaseStrategy.copyWith( type: "SNAPSHOT", preReleaseStrategy: StrategyUtil.all( - appendBranchName, + branchNames, appendSnapshot() ), createTag: false @@ -61,22 +61,40 @@ class SemanticReleasePluginExtension { } def changeLog(Closure closure) { - ConfigureUtil.configure(closure, changeLogService) + ConfigureUtil.configure(closure, changeLog) } def releaseBranches(Closure closure) { - ConfigureUtil.configure(closure, onReleaseBranch) + ConfigureUtil.configure(closure, releaseBranches) } def branchNames(Closure closure) { - ConfigureUtil.configure(closure, appendBranchName) + ConfigureUtil.configure(closure, branchNames) } boolean isRelease(SemVerStrategyState state) { - !state.repoDirty && onReleaseBranch.isReleaseBranch(state.currentBranch.name) && + !state.repoDirty && releaseBranches.isReleaseBranch(state.currentBranch.name) && semanticStrategy.canRelease(state) && project.gradle.startParameter.taskNames.find { it == 'release' } } + @Deprecated + SemanticReleaseChangeLogService getChangeLogService() { + project.logger.warn("semanticRelease.changeLogService is deprecated and will be removed in v2.0.0") + changeLog + } + + @Deprecated + SemanticReleaseCheckBranch getOnReleaseBranch() { + project.logger.warn("semanticRelease.onReleaseBranch is deprecated and will be removed in v2.0.0") + releaseBranches + } + + @Deprecated + SemanticReleaseAppendBranchNameStrategy getAppendBranchName() { + project.logger.warn("semanticRelease.appendBranchName is deprecated and will be removed in v2.0.0") + branchNames + } + private PartialSemVerStrategy appendSnapshot() { return { it.inferredPreRelease ? diff --git a/src/test/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginSpec.groovy b/src/test/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginSpec.groovy index 285bfdc..672a0de 100644 --- a/src/test/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginSpec.groovy +++ b/src/test/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleasePluginSpec.groovy @@ -53,7 +53,29 @@ class SemanticReleasePluginSpec extends ProjectSpec { } then: - project.semanticRelease.changeLogService.breakingChangeKeywords == ['breaks'] + project.semanticRelease.changeLog.breakingChangeKeywords == ['breaks'] + } + + def "can configure the changeLogService using the property"() { + when: + project.with { + apply plugin: PLUGIN + semanticRelease.changeLog.breakingChangeKeywords = ['breaks'] + } + + then: + project.semanticRelease.changeLog.breakingChangeKeywords == ['breaks'] + } + + def "can configure the changeLogService using the deprecated property"() { + when: + project.with { + apply plugin: PLUGIN + semanticRelease.changeLogService.breakingChangeKeywords = ['breaks'] + } + + then: + project.semanticRelease.changeLog.breakingChangeKeywords == ['breaks'] } def "can configure the release branches"() { @@ -68,7 +90,29 @@ class SemanticReleasePluginSpec extends ProjectSpec { } then: - project.semanticRelease.onReleaseBranch.excludes == ['foo'] as Set + project.semanticRelease.releaseBranches.excludes == ['foo'] as Set + } + + def "can configure the release branches using the property"() { + when: + project.with { + apply plugin: PLUGIN + semanticRelease.releaseBranches.exclude 'foo' + } + + then: + project.semanticRelease.releaseBranches.excludes == ['foo'] as Set + } + + def "can configure the release branches using the deprecated property"() { + when: + project.with { + apply plugin: PLUGIN + semanticRelease.onReleaseBranch.exclude 'foo' + } + + then: + project.semanticRelease.releaseBranches.excludes == ['foo'] as Set } def "can configure the branchNames strategy"() { @@ -83,7 +127,29 @@ class SemanticReleasePluginSpec extends ProjectSpec { } then: - project.semanticRelease.appendBranchName.replacePatterns.foo == 'bar' + project.semanticRelease.branchNames.replacePatterns.foo == 'bar' + } + + def "can configure the branchNames using the property"() { + when: + project.with { + apply plugin: PLUGIN + semanticRelease.branchNames.replace 'foo', 'bar' + } + + then: + project.semanticRelease.branchNames.replacePatterns.foo == 'bar' + } + + def "can configure the branchNames using the deprecated property"() { + when: + project.with { + apply plugin: PLUGIN + semanticRelease.appendBranchName.replace 'foo', 'bar' + } + + then: + project.semanticRelease.branchNames.replacePatterns.foo == 'bar' } }