-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
project.version set when updateProjectVersionAfterRelease flag is ena…
…bled | fixes #806
- Loading branch information
Showing
13 changed files
with
213 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/groovy/pl/allegro/tech/build/axion/release/ConfigurationCacheConfiguration.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package pl.allegro.tech.build.axion.release | ||
|
||
class ConfigurationCacheConfiguration { | ||
boolean updateProjectVersionAfterRelease | ||
boolean configurationCacheEnabled | ||
public Closure<String> updateProjectVersion | ||
|
||
ConfigurationCacheConfiguration(boolean updateProjectVersionAfterRelease, boolean configurationCacheEnabled, Closure<String> updateProjectVersion) { | ||
this.updateProjectVersionAfterRelease = updateProjectVersionAfterRelease | ||
this.configurationCacheEnabled = configurationCacheEnabled | ||
this.updateProjectVersion = updateProjectVersion | ||
} | ||
} |
17 changes: 14 additions & 3 deletions
17
src/main/groovy/pl/allegro/tech/build/axion/release/CreateReleaseTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
package pl.allegro.tech.build.axion.release | ||
|
||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.TaskAction | ||
import pl.allegro.tech.build.axion.release.domain.Releaser | ||
import pl.allegro.tech.build.axion.release.domain.scm.ScmService | ||
import pl.allegro.tech.build.axion.release.infrastructure.di.VersionResolutionContext | ||
|
||
abstract class CreateReleaseTask extends BaseAxionTask { | ||
|
||
@Input | ||
boolean configurationCacheEnabled | ||
|
||
@TaskAction | ||
void release() { | ||
VersionResolutionContext context = resolutionContext() | ||
Releaser releaser = context.releaser() | ||
ScmService scmService = context.scmService() | ||
ReleaseBranchesConfiguration releaseBranchesConfiguration = new ReleaseBranchesConfiguration( | ||
context.scmService().isReleaseOnlyOnReleaseBranches(), | ||
scmService.isReleaseOnlyOnReleaseBranches(), | ||
context.repository().currentPosition().getBranch(), | ||
context.scmService().getReleaseBranchNames() | ||
scmService.getReleaseBranchNames() | ||
) | ||
ConfigurationCacheConfiguration configurationCacheConfiguration = new ConfigurationCacheConfiguration( | ||
scmService.isUpdateProjectVersionAfterRelease(), | ||
configurationCacheEnabled, | ||
(version) -> project.setVersion(version) | ||
) | ||
releaser.release(context.rules(), releaseBranchesConfiguration) | ||
releaser.release(context.rules(), releaseBranchesConfiguration, configurationCacheConfiguration) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/groovy/pl/allegro/tech/build/axion/release/Utils.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package pl.allegro.tech.build.axion.release | ||
|
||
import com.github.zafarkhaja.semver.Version | ||
import org.gradle.api.Project | ||
import org.gradle.api.internal.StartParameterInternal | ||
|
||
class Utils { | ||
static boolean isConfigurationCacheEnabled(Project project) { | ||
try { | ||
def gradleVersion = getGradleVersion(project.gradle.gradleVersion) | ||
if (gradleVersion.greaterThan(Version.valueOf("7.6.0"))) { | ||
return project.gradle.startParameter.isConfigurationCacheRequested() | ||
} else if (gradleVersion.greaterThanOrEqualTo(Version.valueOf("7.0.0"))) { | ||
return (project.gradle.startParameter as StartParameterInternal).isConfigurationCache() | ||
} | ||
} catch (e) { | ||
project.logger.quiet("Cannot determine if configuration cache is enabled. Assuming it is not.", e) | ||
return false | ||
} | ||
return false | ||
} | ||
|
||
static Version getGradleVersion(String gradleVersionString) { | ||
def split = gradleVersionString.split("\\.", 3) | ||
if (split.length === 2) { | ||
return Version.forIntegers(split[0].toInteger(), split[1].toInteger()) | ||
} else if (split.length === 3) { | ||
return Version.forIntegers(split[0].toInteger(), split[1].toInteger(), split[2].toInteger()) | ||
} else { | ||
throw new IllegalStateException("Cannot parse Gradle version: $gradleVersionString") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.