Skip to content

Commit

Permalink
fix(extension): rename properties to match the methods with properties
Browse files Browse the repository at this point in the history
Closes #2
  • Loading branch information
tschulte committed Sep 14, 2015
1 parent 78b2f74 commit ca2e1de
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SemanticReleasePlugin implements Plugin<Project> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ 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

@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,
Expand All @@ -52,7 +52,7 @@ class SemanticReleasePluginExtension {
snapshotStrategy = releaseStrategy.copyWith(
type: "SNAPSHOT",
preReleaseStrategy: StrategyUtil.all(
appendBranchName,
branchNames,
appendSnapshot()
),
createTag: false
Expand All @@ -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 ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"() {
Expand All @@ -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"() {
Expand All @@ -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'
}

}

0 comments on commit ca2e1de

Please sign in to comment.