File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 66
77lint :
88 @./gradlew pmdMain
9+ @./gradlew lintProjectVersion
910
1011test :
1112 @./gradlew test
Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ subprojects {
113113 logger. warn(" VERSION file not found in project '${ project.path} '. Skipping version setting." )
114114 }
115115
116+ tasks. register(' lintProjectVersion' , VersionCheckTask ) {}
117+
116118 java {
117119 withSourcesJar()
118120 withJavadocJar()
Original file line number Diff line number Diff line change 1+ import org.gradle.api.DefaultTask
2+ import org.gradle.api.tasks.TaskAction
3+ import org.gradle.api.tasks.Input
4+ import org.gradle.api.GradleException
5+
6+ class VersionCheckTask extends DefaultTask {
7+ @Input
8+ def versionRegex = ~/ ^[0-1]\.\d +\.\d +$/
9+
10+ @TaskAction
11+ def checkVersion () {
12+ File versionFile = project. file(' VERSION' )
13+
14+ if (! versionFile. exists()) {
15+ logger. quiet(" VERSION file not found in subproject: ${ project.name} " )
16+ return
17+ }
18+
19+ def version = versionFile. text. trim()
20+ if (! (version =~ versionRegex)) {
21+ throw new GradleException (" Version '${ version} ' in project '${ project.name} ' does not match regex: ${ versionRegex} " )
22+ }
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments