Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fmt:

lint:
@./gradlew pmdMain
@./gradlew lintProjectVersion

test:
@./gradlew test
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ subprojects {
logger.warn("VERSION file not found in project '${project.path}'. Skipping version setting.")
}

tasks.register('lintProjectVersion', VersionCheckTask) {}

java {
withSourcesJar()
withJavadocJar()
Expand Down
24 changes: 24 additions & 0 deletions buildSrc/src/main/groovy/VersionCheckTask.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.Input
import org.gradle.api.GradleException

class VersionCheckTask extends DefaultTask {
@Input
def versionRegex = ~/^[0-1]\.\d+\.\d+$/

@TaskAction
def checkVersion() {
File versionFile = project.file('VERSION')

if (!versionFile.exists()) {
logger.quiet("VERSION file not found in subproject: ${project.name}")
return
}

def version = versionFile.text.trim()
if (!(version =~ versionRegex)) {
throw new GradleException("Version '${version}' in project '${project.name}' does not match regex: ${versionRegex}")
}
}
}