Added the Gradle project directory as the configuration properties file location. Closes #6
This commit is contained in:
parent
e47f762a6f
commit
6081bdfdd5
6 changed files with 70 additions and 15 deletions
16
.idea/checkstyle-idea.xml
generated
Normal file
16
.idea/checkstyle-idea.xml
generated
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CheckStyle-IDEA">
|
||||
<option name="configuration">
|
||||
<map>
|
||||
<entry key="checkstyle-version" value="8.19" />
|
||||
<entry key="copy-libs" value="true" />
|
||||
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
|
||||
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
|
||||
<entry key="scan-before-checkin" value="false" />
|
||||
<entry key="scanscope" value="JavaOnly" />
|
||||
<entry key="suppress-errors" value="false" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -6,20 +6,20 @@ plugins {
|
|||
`maven-publish`
|
||||
jacoco
|
||||
id("com.github.ben-manes.versions") version "0.21.0"
|
||||
id("com.gradle.build-scan") version "2.2.1"
|
||||
id("com.gradle.build-scan") version "2.3"
|
||||
id("com.gradle.plugin-publish") version "0.10.1"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.0.0-RC14"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "7.3.0"
|
||||
id("org.sonarqube") version "2.7"
|
||||
id("org.jmailen.kotlinter") version "1.25.2"
|
||||
id("org.sonarqube") version "2.7.1"
|
||||
}
|
||||
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
group = "net.thauvin.erik.gradle"
|
||||
|
||||
var github = "https://github.com/ethauvin/semver-gradle"
|
||||
var packageName = "net.thauvin.erik.gradle.semver"
|
||||
|
||||
var spek_version = "2.0.2"
|
||||
var spek_version = "2.0.5"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
|
@ -56,10 +56,6 @@ tasks {
|
|||
}
|
||||
}
|
||||
|
||||
"check" {
|
||||
dependsOn("ktlintCheck")
|
||||
}
|
||||
|
||||
"sonarqube" {
|
||||
dependsOn("jacocoTestReport")
|
||||
}
|
||||
|
@ -81,6 +77,12 @@ detekt {
|
|||
baseline = project.rootDir.resolve("detekt-baseline.xml")
|
||||
}
|
||||
|
||||
kotlinter {
|
||||
ignoreFailures = false
|
||||
reporters = arrayOf("html")
|
||||
experimentalRules = false
|
||||
}
|
||||
|
||||
sonarqube {
|
||||
properties {
|
||||
property("sonar.projectName", "semver-gradle")
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -59,7 +59,11 @@ class SemverPlugin : Plugin<Project> {
|
|||
}
|
||||
|
||||
private fun afterEvaluate(project: Project) {
|
||||
val propsFile = File(config.properties)
|
||||
val propsFile = if (File(config.properties).isAbsolute) {
|
||||
File(config.properties)
|
||||
} else {
|
||||
File("${project.projectDir}${File.separator}${config.properties}")
|
||||
}
|
||||
|
||||
if (project.version != "unspecified") {
|
||||
project.logger.warn(
|
||||
|
|
|
@ -70,12 +70,12 @@ object Utils {
|
|||
var isNew = false
|
||||
val props = Properties()
|
||||
file.apply {
|
||||
if (!exists()) {
|
||||
if (!createNewFile()) {
|
||||
throw GradleException("Unable to create: `$absoluteFile`")
|
||||
} else {
|
||||
try {
|
||||
if (!exists() && createNewFile()) {
|
||||
isNew = true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
throw GradleException("Unable to create: `$absoluteFile`", e)
|
||||
}
|
||||
if (canReadFile()) {
|
||||
FileInputStream(this).reader().use { reader ->
|
||||
|
|
|
@ -32,11 +32,13 @@
|
|||
package net.thauvin.erik.gradle.semver
|
||||
|
||||
import net.thauvin.erik.gradle.semver.Utils.canReadFile
|
||||
import org.gradle.api.GradleException
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.gherkin.Feature
|
||||
import java.io.File
|
||||
import java.util.Properties
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
|
@ -46,6 +48,7 @@ object UtilsSpec : Spek({
|
|||
val version = Version()
|
||||
val config = SemverConfig()
|
||||
val propsFile = File("test.properties")
|
||||
val propsLocked = File("locked.properties")
|
||||
lateinit var props: Properties
|
||||
|
||||
Scenario("Save/Load Properties") {
|
||||
|
@ -167,5 +170,35 @@ object UtilsSpec : Spek({
|
|||
assertEquals(version.buildMeta, "007")
|
||||
}
|
||||
}
|
||||
|
||||
Scenario("Save to locked properties") {
|
||||
Given("the locked properties") {
|
||||
propsLocked.createNewFile()
|
||||
propsLocked.setReadOnly()
|
||||
config.properties = propsLocked.name
|
||||
}
|
||||
|
||||
Then("saving the locked properties file") {
|
||||
assertFailsWith<GradleException> {
|
||||
Utils.saveProperties(config, version)
|
||||
}
|
||||
propsLocked.delete()
|
||||
}
|
||||
}
|
||||
|
||||
Scenario("Load locked properties") {
|
||||
lateinit var locked: File
|
||||
|
||||
Given("the locked location") {
|
||||
locked = File("locked")
|
||||
}
|
||||
|
||||
Then("loading locked properties") {
|
||||
assertFailsWith<GradleException> {
|
||||
Utils.loadProperties(File(locked, propsLocked.name))
|
||||
}
|
||||
locked.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue