diff --git a/build.gradle b/build.gradle index e4dc35b..35d1dce 100644 --- a/build.gradle +++ b/build.gradle @@ -6,19 +6,17 @@ plugins { subprojects { group = 'com.medly.apifi' + + repositories { + jcenter() + } } -configure(subprojects.findAll {it.name != 'plugin'}) { +configure(subprojects.findAll {it.name != 'plugin'}) { // no java component publishing for plugin apply plugin: 'org.jetbrains.kotlin.jvm' apply plugin: 'org.jetbrains.kotlin.kapt' apply plugin: "com.kdabir.mksrc" apply plugin: "maven-publish" - - - repositories { - mavenCentral() - jcenter() - } dependencies { implementation platform('org.jetbrains.kotlin:kotlin-bom') @@ -82,14 +80,16 @@ project(":cli") { project(":runtime") { dependencies { - kapt(platform("io.micronaut:micronaut-bom:$micronautVersion")) - kapt("io.micronaut:micronaut-inject-java") + // todo do we need kapt in this project? + // kapt(platform("io.micronaut:micronaut-bom:$micronautVersion")) + // kapt("io.micronaut:micronaut-inject-java") implementation(platform("io.micronaut:micronaut-bom:$micronautVersion")) implementation("io.micronaut:micronaut-inject") implementation("io.micronaut:micronaut-http") implementation("io.micronaut:micronaut-http-server") - kaptTest("io.micronaut:micronaut-inject-java") + // todo do we need kapt in this project? + // kaptTest("io.micronaut:micronaut-inject-java") } } diff --git a/plugin/build.gradle b/plugin/build.gradle index 0d41c9f..75bf4af 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -6,3 +6,13 @@ plugins { dependencies { implementation project(":codegen") } + +project.afterEvaluate { + tasks.withType(ProcessResources) { processResources -> + inputs.property('projectVersion', project.version) + + filesMatching("version.properties") { + expand('projectVersion': project.version) + } + } +} diff --git a/plugin/src/main/groovy/apifi/ApifiCodegen.groovy b/plugin/src/main/groovy/apifi/ApifiCodegen.groovy index 22178ee..cc6eba2 100644 --- a/plugin/src/main/groovy/apifi/ApifiCodegen.groovy +++ b/plugin/src/main/groovy/apifi/ApifiCodegen.groovy @@ -1,12 +1,14 @@ package apifi import apifi.codegen.* +import groovy.transform.CompileStatic import org.gradle.api.DefaultTask import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.TaskAction +@CompileStatic class ApifiCodegen extends DefaultTask { @InputFile diff --git a/plugin/src/main/groovy/apifi/VersionLoader.groovy b/plugin/src/main/groovy/apifi/VersionLoader.groovy new file mode 100644 index 0000000..c2cd578 --- /dev/null +++ b/plugin/src/main/groovy/apifi/VersionLoader.groovy @@ -0,0 +1,22 @@ +package apifi + +import groovy.transform.CompileStatic + +@CompileStatic +class VersionLoader { + static final String VERSION_PROPERTIES_PATH = "/version.properties" + + private static String load() { + def stream = VersionLoader.getResourceAsStream(VERSION_PROPERTIES_PATH) + if (stream == null) { + throw new RuntimeException("""\ + Could not load version.properties. + This could happen when plugin jar is deleted + Try Stopping Gradle Daemon (gradle --stop)""".stripIndent()) + } + final Properties versions = new Properties() + versions.load(stream); + + return versions['project.version'] ?: 'unspecified' + } +} diff --git a/plugin/src/main/groovy/com.medly.apifi.gradle b/plugin/src/main/groovy/com.medly.apifi.gradle index 2e59963..cfd1171 100644 --- a/plugin/src/main/groovy/com.medly.apifi.gradle +++ b/plugin/src/main/groovy/com.medly.apifi.gradle @@ -1,5 +1,7 @@ +def apifiVersion = apifi.VersionLoader.load() + dependencies { - implementation(group: 'com.medly.apifi', name: 'runtime', version: this.getVersion()) + implementation(group: 'com.medly.apifi', name: 'runtime', version: apifiVersion) } tasks.register('apifi', apifi.ApifiCodegen) diff --git a/plugin/src/main/resources/version.properties b/plugin/src/main/resources/version.properties new file mode 100644 index 0000000..041b91d --- /dev/null +++ b/plugin/src/main/resources/version.properties @@ -0,0 +1 @@ +project.version=${projectVersion}