mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Added parameters to autoGitTag directive.
This commit is contained in:
parent
99c447805e
commit
4f32f0ba2f
2 changed files with 17 additions and 10 deletions
|
@ -6,10 +6,10 @@ import com.google.inject.Inject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class Git @Inject constructor() {
|
class Git @Inject constructor() {
|
||||||
fun maybeTagRelease(project: Project, uploadResult: TaskResult, autoGitTag: Boolean) : TaskResult {
|
fun maybeTagRelease(project: Project, uploadResult: TaskResult, autoGitTag: Triple<Boolean, String, String>) : TaskResult {
|
||||||
val result =
|
val result =
|
||||||
if (uploadResult.success && autoGitTag) {
|
if (uploadResult.success && autoGitTag.first) {
|
||||||
val tagSuccess = tagRelease(project)
|
val tagSuccess = tagRelease(project, autoGitTag)
|
||||||
if (! tagSuccess) {
|
if (! tagSuccess) {
|
||||||
TaskResult(false, "Couldn't tag the project")
|
TaskResult(false, "Couldn't tag the project")
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,16 +21,17 @@ class Git @Inject constructor() {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tagRelease(project: Project) : Boolean {
|
private fun tagRelease(project: Project, autoGitTag: Triple<Boolean, String, String>) : Boolean {
|
||||||
val success = try {
|
val success = try {
|
||||||
log(2, "Tagging this release as \"${project.version}\"")
|
val version = if (autoGitTag.second.isNullOrBlank()) project.version else autoGitTag.second
|
||||||
|
log(2, "Tagging this release as \"$version\"")
|
||||||
val repo = org.eclipse.jgit.storage.file.FileRepositoryBuilder()
|
val repo = org.eclipse.jgit.storage.file.FileRepositoryBuilder()
|
||||||
.setGitDir(File(KFiles.joinDir(project.directory, ".git")))
|
.setGitDir(File(KFiles.joinDir(project.directory, ".git")))
|
||||||
.readEnvironment()
|
.readEnvironment()
|
||||||
.findGitDir()
|
.findGitDir()
|
||||||
.build()
|
.build()
|
||||||
val git = org.eclipse.jgit.api.Git(repo)
|
val git = org.eclipse.jgit.api.Git(repo)
|
||||||
val ref = git.tag().setName(project.version).call()
|
val ref = git.tag().setName(version).setMessage(autoGitTag.third).call()
|
||||||
git.push().setPushTags().call()
|
git.push().setPushTags().call()
|
||||||
true
|
true
|
||||||
} catch(ex: Exception) {
|
} catch(ex: Exception) {
|
||||||
|
|
|
@ -191,13 +191,16 @@ class PublishPlugin @Inject constructor(val files: KFiles, val factory: PomGener
|
||||||
|
|
||||||
data class GithubConfig(val project: Project) {
|
data class GithubConfig(val project: Project) {
|
||||||
val files = arrayListOf<File>()
|
val files = arrayListOf<File>()
|
||||||
|
var autoGitTag = Triple(true, project.version!!, "")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, automatically tag this release with the current version number and push that tag to origin when
|
* If true, automatically tag this release with the current version number and push that tag to origin when
|
||||||
* the uploadGithub task is called.
|
* the uploadGithub task is called.
|
||||||
*/
|
*/
|
||||||
@Directive
|
@Directive
|
||||||
var autoGitTag: Boolean = false
|
fun autoGitTag(auto: Boolean = autoGitTag.first, tag: String = project.version!!, message: String = autoGitTag.third) {
|
||||||
|
autoGitTag = Triple(auto, tag, message)
|
||||||
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun file(filePath: String, url: String) {
|
fun file(filePath: String, url: String) {
|
||||||
|
@ -213,6 +216,9 @@ fun Project.github(init: GithubConfig.() -> Unit): GithubConfig =
|
||||||
}
|
}
|
||||||
|
|
||||||
data class BintrayConfig(val project: Project) {
|
data class BintrayConfig(val project: Project) {
|
||||||
|
val files = arrayListOf<Pair<String, String>>()
|
||||||
|
var autoGitTag = Triple(true, project.version!!, "")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the uploaded file will be published in your personal space (e.g. https://dl.bintray.com/cbeust/maven).
|
* If true, the uploaded file will be published in your personal space (e.g. https://dl.bintray.com/cbeust/maven).
|
||||||
* Once the file is uploaded there, it can be automatically synchronized to JCenter by linking your project to
|
* Once the file is uploaded there, it can be automatically synchronized to JCenter by linking your project to
|
||||||
|
@ -233,9 +239,9 @@ data class BintrayConfig(val project: Project) {
|
||||||
* the uploadBintray task is called.
|
* the uploadBintray task is called.
|
||||||
*/
|
*/
|
||||||
@Directive
|
@Directive
|
||||||
var autoGitTag: Boolean = true
|
fun autoGitTag(auto: Boolean = autoGitTag.first, tag: String = project.version!!, message: String = autoGitTag.third) {
|
||||||
|
autoGitTag = Triple(auto, tag, message)
|
||||||
val files = arrayListOf<Pair<String, String>>()
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun file(filePath: String, url: String) {
|
fun file(filePath: String, url: String) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue