|
| 1 | +/* |
| 2 | + * Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | + * You may not use this file except in compliance with the License. |
| 6 | + * A copy of the License is located at |
| 7 | + * |
| 8 | + * http://aws.amazon.com/apache2.0 |
| 9 | + * |
| 10 | + * or in the "license" file accompanying this file. This file is distributed |
| 11 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | + * express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +import java.util.Properties |
| 17 | + |
| 18 | +plugins { |
| 19 | + id("java-library") |
| 20 | + id("maven-publish") |
| 21 | + alias(libs.plugins.kotlin.jvm) |
| 22 | +} |
| 23 | + |
| 24 | +java { |
| 25 | + withSourcesJar() |
| 26 | + withJavadocJar() |
| 27 | +} |
| 28 | + |
| 29 | +kotlin { |
| 30 | + jvmToolchain(17) |
| 31 | +} |
| 32 | + |
| 33 | +fun readVersion() = Properties().run { |
| 34 | + file("../version.properties").inputStream().use { load(it) } |
| 35 | + get("VERSION_NAME").toString() |
| 36 | +} |
| 37 | + |
| 38 | +project.setProperty("VERSION_NAME", readVersion()) |
| 39 | + |
| 40 | +apply(from = rootProject.file("configuration/publishing.gradle")) |
| 41 | + |
| 42 | +val packageInfoGenerator by tasks.registering { |
| 43 | + val constantsDir = project.layout.buildDirectory.dir("generated/sources/constants/java") |
| 44 | + val outputFile = constantsDir.get().file("com/amplifyframework/aws/appsync/core/util/PackageInfo.kt").asFile |
| 45 | + inputs.property("version", version) |
| 46 | + outputs.dir(constantsDir) |
| 47 | + doLast { |
| 48 | + outputFile.parentFile.mkdirs() |
| 49 | + val properties = inputs.properties |
| 50 | + val version by properties |
| 51 | + outputFile.writeText( |
| 52 | + """package com.amplifyframework.aws.appsync.core.util |
| 53 | + | |
| 54 | + |internal object PackageInfo { |
| 55 | + | const val version = "$version" |
| 56 | + |} |
| 57 | + | |
| 58 | + """.trimMargin() |
| 59 | + ) |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +sourceSets.main { |
| 64 | + java.srcDir(packageInfoGenerator) |
| 65 | +} |
| 66 | + |
| 67 | +dependencies { |
| 68 | + |
| 69 | + testImplementation(libs.test.junit) |
| 70 | + testImplementation(libs.test.mockk) |
| 71 | + testImplementation(libs.test.kotlin.coroutines) |
| 72 | + testImplementation(libs.test.kotest.assertions) |
| 73 | +} |
0 commit comments