@@ -29,17 +29,107 @@ package io.spine.internal.dependency
29
29
/* *
30
30
* Dependencies on ProtoData modules.
31
31
*
32
+ * In order to use locally published ProtoData version instead of the version from a public plugin
33
+ * registry, set the `PROTODATA_VERSION` and/or the `PROTODATA_DF_VERSION` environment variables
34
+ * and stop the Gradle daemons so that Gradle observes the env change:
35
+ * ```
36
+ * export PROTODATA_VERSION=0.43.0-local
37
+ * export PROTODATA_DF_VERSION=0.41.0
38
+ *
39
+ * ./gradle --stop
40
+ * ./gradle build # Conduct the intended checks.
41
+ * ```
42
+ *
43
+ * Then, in order to reset the console to run the usual versions again, remove the values of
44
+ * the environment variables and stop the daemon:
45
+ * ```
46
+ * export PROTODATA_VERSION=""
47
+ * export PROTODATA_DF_VERSION=""
48
+ *
49
+ * ./gradle --stop
50
+ * ```
51
+ *
32
52
* See [`SpineEventEngine/ProtoData`](https://github.com/SpineEventEngine/ProtoData/).
33
53
*/
34
- @Suppress(" unused" , " ConstPropertyName" )
54
+ @Suppress(
55
+ " unused" /* Some subprojects do not use ProtoData directly. */ ,
56
+ " ConstPropertyName" /* We use custom convention for artifact properties. */ ,
57
+ " MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */ ,
58
+ " KDocUnresolvedReference" /* Referencing private properties in constructor KDoc. */
59
+ )
35
60
object ProtoData {
36
- const val version = " 0.11.4"
37
- const val dogfoodingVersion = " 0.11.0"
38
61
const val group = " io.spine.protodata"
39
- const val compiler = " $group : protodata-compiler: $version "
62
+ const val pluginId = " io.spine. protodata"
40
63
41
- const val codegenJava = " io.spine.protodata:protodata-codegen-java:$version "
64
+ /* *
65
+ * The version of ProtoData dependencies.
66
+ */
67
+ val version: String
68
+ private const val fallbackVersion = " 0.12.0"
42
69
43
- const val pluginId = " io.spine.protodata"
44
- const val pluginLib = " ${Spine .group} :protodata:$version "
70
+ /* *
71
+ * The distinct version of ProtoData used by other build tools.
72
+ *
73
+ * When ProtoData is used both for building the project and as a part of the Project's
74
+ * transitional dependencies, this is the version used to build the project itself.
75
+ */
76
+ val dogfoodingVersion: String
77
+ private const val fallbackDfVersion = " 0.9.11"
78
+
79
+ /* *
80
+ * The artifact for the ProtoData Gradle plugin.
81
+ */
82
+ val pluginLib: String
83
+
84
+ val api
85
+ get() = " $group :protodata-api:$version "
86
+ val compiler
87
+ get() = " $group :protodata-compiler:$version "
88
+ val codegenJava
89
+ get() = " $group :protodata-codegen-java:$version "
90
+
91
+ /* *
92
+ * An env variable storing a custom [version].
93
+ */
94
+ private const val VERSION_ENV = " PROTODATA_VERSION"
95
+
96
+ /* *
97
+ * An env variable storing a custom [dogfoodingVersion].
98
+ */
99
+ private const val DF_VERSION_ENV = " PROTODATA_DF_VERSION"
100
+
101
+ /* *
102
+ * Sets up the versions and artifacts for the build to use.
103
+ *
104
+ * If either [VERSION_ENV] or [DF_VERSION_ENV] is set, those versions are used instead of
105
+ * the hardcoded ones. Also, in this mode, the [pluginLib] coordinates are changed so that
106
+ * it points at a locally published artifact. Otherwise, it points at an artifact that would be
107
+ * published to a public plugin registry.
108
+ */
109
+ init {
110
+ val experimentVersion = System .getenv(VERSION_ENV )
111
+ val experimentDfVersion = System .getenv(DF_VERSION_ENV )
112
+ if (experimentVersion?.isNotBlank() == true || experimentDfVersion?.isNotBlank() == true ) {
113
+ version = experimentVersion ? : fallbackVersion
114
+ dogfoodingVersion = experimentDfVersion ? : fallbackDfVersion
115
+
116
+ pluginLib = " ${group} :gradle-plugin:$version "
117
+ println ("""
118
+
119
+ ❗ Running an experiment with ProtoData. ❗
120
+ -----------------------------------------
121
+ Regular version = v$version
122
+ Dogfooding version = v$dogfoodingVersion
123
+
124
+ ProtoData Gradle plugin can now be loaded from Maven Local.
125
+
126
+ To reset the versions, erase the `$$VERSION_ENV ` and `$$DF_VERSION_ENV ` environment variables.
127
+
128
+ """ .trimIndent())
129
+ } else {
130
+ version = fallbackVersion
131
+ dogfoodingVersion = fallbackDfVersion
132
+ pluginLib = " ${Spine .group} :protodata:$version "
133
+ }
134
+ }
45
135
}
0 commit comments