Skip to content

Commit f9e7e55

Browse files
ProjectEnv constants: add for plugin IDs
1 parent 76bba19 commit f9e7e55

7 files changed

Lines changed: 19 additions & 9 deletions

File tree

objectbox-gradle-plugin/src/main/kotlin/io/objectbox/gradle/ObjectBoxGradlePlugin.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ import org.gradle.api.tasks.compile.JavaCompile
4848
open class ObjectBoxGradlePlugin : Plugin<Project> {
4949

5050
/**
51-
* The Gradle plugin id as registered in resources/META-INF/gradle-plugins.
51+
* The Gradle plugin id as registered in resources/META-INF/gradle-plugins (but actually configured using the
52+
* Gradle plugin development plugin in the build script using the gradlePlugin extension).
5253
*/
53-
internal open val pluginId = "io.objectbox"
54+
internal open val pluginId = Const.PLUGIN_ID
5455

5556
private val buildTracker = GradleBuildTracker("GradlePlugin")
5657

objectbox-gradle-plugin/src/main/kotlin/io/objectbox/gradle/ObjectBoxSyncGradlePlugin.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,23 @@
1818

1919
package io.objectbox.gradle
2020

21+
import io.objectbox.gradle.ProjectEnv.Const
22+
2123

2224
/**
2325
* Like [ObjectBoxGradlePlugin], but adds native libraries that are sync-enabled as dependencies.
2426
*/
2527
class ObjectBoxSyncGradlePlugin : ObjectBoxGradlePlugin() {
2628

27-
override val pluginId = "io.objectbox.sync"
29+
override val pluginId = Const.SYNC_PLUGIN_ID
2830

2931
override fun getLibWithSyncVariantPrefix(): String {
3032
// Use Sync version.
3133
return LIBRARY_NAME_PREFIX_SYNC
3234
}
3335

3436
override fun getLibWithSyncVariantVersion(): String {
35-
return ProjectEnv.Const.OBX_DATABASE_SYNC_VERSION
37+
return Const.OBX_DATABASE_SYNC_VERSION
3638
}
3739

3840
}

objectbox-gradle-plugin/src/main/kotlin/io/objectbox/gradle/ProjectEnv.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import java.util.*
2626

2727
class ProjectEnv(val project: Project) {
2828
object Const {
29+
const val PLUGIN_ID = "io.objectbox"
30+
const val SYNC_PLUGIN_ID = "io.objectbox.sync"
2931
const val EXTENSION_NAME: String = "objectbox"
3032
const val OBX_PLUGIN_VERSION = GradlePluginBuildConfig.VERSION
3133
const val OBX_JAVA_VERSION = GradlePluginBuildConfig.APPLIES_JAVA_VERSION

objectbox-gradle-plugin/src/test/kotlin/io/objectbox/gradle/GradleTestRunner.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package io.objectbox.gradle
2020

21+
import io.objectbox.gradle.ProjectEnv.Const
2122
import org.gradle.testkit.runner.BuildResult
2223
import org.gradle.testkit.runner.GradleRunner
2324
import org.intellij.lang.annotations.Language
@@ -76,7 +77,7 @@ class GradleTestRunner(
7677
7778
plugins {
7879
${additionalPlugins.joinToString(separator = "\n") { "id(\"$it\")" }}
79-
id("io.objectbox")
80+
id("${Const.PLUGIN_ID}")
8081
}
8182
8283
java {

objectbox-gradle-plugin/src/test/kotlin/io/objectbox/gradle/PluginApplyTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import org.junit.Assert.assertTrue
3232
*/
3333
abstract class PluginApplyTest {
3434

35-
open val pluginId = "io.objectbox"
35+
open val pluginId = Const.PLUGIN_ID
3636
open val expectedLibWithSyncVariantPrefix = "objectbox"
3737
open val expectedLibWithSyncVariantVersion = Const.OBX_DATABASE_VERSION
3838

objectbox-gradle-plugin/src/test/kotlin/io/objectbox/gradle/SyncPluginApplyAndroidTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
package io.objectbox.gradle
2020

21+
import io.objectbox.gradle.ProjectEnv.Const
22+
2123
/**
2224
* Base class to test applying [ObjectBoxSyncGradlePlugin] configures a Java or Kotlin Android Gradle project as expected.
2325
*/
2426
abstract class SyncPluginApplyAndroidTest : PluginApplyAndroidTest() {
2527

26-
override val pluginId = "io.objectbox.sync"
28+
override val pluginId = Const.SYNC_PLUGIN_ID
2729
override val expectedLibWithSyncVariantPrefix = "objectbox-sync"
28-
override val expectedLibWithSyncVariantVersion = ProjectEnv.Const.OBX_DATABASE_SYNC_VERSION
30+
override val expectedLibWithSyncVariantVersion = Const.OBX_DATABASE_SYNC_VERSION
2931

3032
}

objectbox-gradle-plugin/src/test/kotlin/io/objectbox/gradle/SyncPluginApplyJavaTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
package io.objectbox.gradle
2020

21+
import io.objectbox.gradle.ProjectEnv.Const
22+
2123

2224
/**
2325
* Tests applying [ObjectBoxSyncGradlePlugin] configures a Java or Kotlin desktop Gradle project as expected.
2426
*/
2527
class SyncPluginApplyJavaTest : PluginApplyJavaTest() {
2628

27-
override val pluginId = "io.objectbox.sync"
29+
override val pluginId = Const.SYNC_PLUGIN_ID
2830
override val expectedLibWithSyncVariantPrefix = "objectbox-sync"
2931
override val expectedLibWithSyncVariantVersion = ProjectEnv.Const.OBX_DATABASE_SYNC_VERSION
3032

0 commit comments

Comments
 (0)