Add plugin test
This commit is contained in:
parent
3140758842
commit
7680845ecd
7 changed files with 71 additions and 19 deletions
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
||||||
|
semver-gradle
|
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
|
@ -2,10 +2,7 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$/examples/annotation-processor/java" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
<file type="web" url="file://$PROJECT_DIR$/examples/annotation-processor/kotlin" />
|
|
||||||
<file type="web" url="file://$PROJECT_DIR$/examples/java" />
|
|
||||||
<file type="web" url="file://$PROJECT_DIR$/examples/kotlin" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="JavaScriptSettings">
|
<component name="JavaScriptSettings">
|
||||||
<option name="languageLevel" value="ES6" />
|
<option name="languageLevel" value="ES6" />
|
||||||
|
|
|
@ -2,8 +2,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.github.ben-manes.versions") version "0.52.0"
|
id("com.github.ben-manes.versions") version "0.52.0"
|
||||||
|
@ -16,7 +14,7 @@ plugins {
|
||||||
kotlin("jvm") version "2.0.21"
|
kotlin("jvm") version "2.0.21"
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.0.5"
|
version = "1.0.5-SNAPSHOT"
|
||||||
group = "net.thauvin.erik.gradle"
|
group = "net.thauvin.erik.gradle"
|
||||||
|
|
||||||
val github = "https://github.com/ethauvin/semver-gradle"
|
val github = "https://github.com/ethauvin/semver-gradle"
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'application'
|
id 'application'
|
||||||
id("com.github.ben-manes.versions") version "0.52.0"
|
id("net.thauvin.erik.gradle.semver")
|
||||||
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultTasks 'run'
|
defaultTasks 'run'
|
||||||
|
@ -16,17 +15,18 @@ application {
|
||||||
|
|
||||||
def f = new File("version.properties")
|
def f = new File("version.properties")
|
||||||
|
|
||||||
def semverProcessor = 'net.thauvin.erik:semver:1.2.0'
|
def semverProcessor = 'net.thauvin.erik:semver:1.2.2-SNAPSHOT'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
annotationProcessor semverProcessor
|
annotationProcessor semverProcessor
|
||||||
compileOnly semverProcessor
|
compileOnly semverProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
}
|
|
||||||
|
|
||||||
application {
|
application {
|
||||||
println project.version
|
println project.version
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
|
@ -49,8 +49,8 @@ run {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task echoVersion(type:Exec) {
|
tasks.register('echoVersion', Exec) {
|
||||||
commandLine('echo', "${-> version}")
|
commandLine('echo', "${-> version}")
|
||||||
}
|
}
|
||||||
|
|
||||||
semver {
|
semver {
|
||||||
|
|
|
@ -48,11 +48,9 @@ open class SemverIncrementBuildMetaTask @Inject constructor(
|
||||||
description = "Increments Build version metadata."
|
description = "Increments Build version metadata."
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
@Input
|
@Input
|
||||||
var buildMeta: String = ""
|
var buildMeta: String = ""
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun increment() {
|
fun increment() {
|
||||||
if (version.buildMeta != buildMeta) {
|
if (version.buildMeta != buildMeta) {
|
||||||
|
|
|
@ -55,7 +55,6 @@ open class SemverIncrementTask @Inject constructor(
|
||||||
} version number."
|
} version number."
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun increment() {
|
fun increment() {
|
||||||
version.increment(
|
version.increment(
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* SemverPluginTest.kt
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018-2025, Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of this project nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.thauvin.erik.gradle.semver
|
||||||
|
|
||||||
|
import org.gradle.testkit.runner.GradleRunner
|
||||||
|
import org.gradle.testkit.runner.TaskOutcome.FAILED
|
||||||
|
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
|
||||||
|
import org.junit.Test
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
|
||||||
|
class SemverPluginTest {
|
||||||
|
@Test
|
||||||
|
fun testSemverPlugin() {
|
||||||
|
val result = GradleRunner.create()
|
||||||
|
.withProjectDir(File("examples/test/"))
|
||||||
|
.withPluginClasspath()
|
||||||
|
.withArguments("incrementBuildMeta", "run")
|
||||||
|
.forwardOutput()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
assertTrue(result.output.contains("version.buildmeta="))
|
||||||
|
assertEquals(SUCCESS, result.task(":incrementBuildMeta")?.outcome ?: FAILED)
|
||||||
|
assertEquals(SUCCESS, result.task(":run")?.outcome ?: FAILED)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue