-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Evaluate the version immediately
- Loading branch information
Showing
4 changed files
with
12 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,17 @@ | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.kotlin.dsl.register | ||
import kotlin.io.path.readBytes | ||
|
||
abstract class ProjectVersion : DefaultTask() { | ||
@TaskAction | ||
fun action() { | ||
try { | ||
val version = | ||
project.rootDir | ||
.toPath() | ||
.resolve("version") | ||
.readBytes() | ||
.toString(Charsets.UTF_8) | ||
logger.info("Read $version") | ||
project.version = version | ||
} catch (ex: Exception) { | ||
logger.warn("Unable to fetch version because of exception", ex) | ||
} | ||
} | ||
} | ||
|
||
class ProjectVersionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
target.tasks.register<ProjectVersion>("projectVersion") | ||
override fun apply(project: Project) { | ||
val version = | ||
project.rootDir | ||
.toPath() | ||
.resolve("version") | ||
.readBytes() | ||
.toString(Charsets.UTF_8) | ||
project.getLogger().info("Read $version") | ||
project.version = version | ||
project.setProperty("version", version) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,6 @@ tasks.withType(JavaCompile).configureEach { | |
//"-Werror" | ||
] | ||
|
||
dependsOn("projectVersion") | ||
|
||
} | ||
|
||
|
||
|
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,6 +1,7 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'penna.publishing' | ||
id 'penna.build.projectVersion' | ||
id 'pmd' | ||
} | ||
|
||
|