Skip to content

Commit 599d616

Browse files
authored
Align init script with version in TeamCity plugin (#325)
1 parent a863c00 commit 599d616

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

src/main/resources/hudson/plugins/gradle/injection/init-script.gradle

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,21 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
167167
}
168168
}
169169

170+
void applyPluginExternally(PluginManager pluginManager, String pluginClassName) {
171+
def externallyApplied = 'gradle.enterprise.externally-applied'
172+
def oldValue = System.getProperty(externallyApplied)
173+
System.setProperty(externallyApplied, 'true')
174+
try {
175+
pluginManager.apply(initscript.classLoader.loadClass(pluginClassName))
176+
} finally {
177+
if (oldValue == null) {
178+
System.clearProperty(externallyApplied)
179+
} else {
180+
System.setProperty(externallyApplied, oldValue)
181+
}
182+
}
183+
}
184+
170185
static def extensionsWithPublicType(def container, String publicType) {
171186
container.extensions.extensionsSchema.elements.findAll { it.publicType.concreteClass.name == publicType }
172187
}
@@ -191,17 +206,3 @@ static String escapeChar(char ch) {
191206
static boolean isNotAtLeast(String versionUnderTest, String referenceVersion) {
192207
GradleVersion.version(versionUnderTest) < GradleVersion.version(referenceVersion)
193208
}
194-
195-
void applyPluginExternally(PluginManager pluginManager, String pluginClassName) {
196-
def oldValue = System.getProperty('gradle.enterprise.externally-applied')
197-
System.setProperty('gradle.enterprise.externally-applied', 'true')
198-
try {
199-
pluginManager.apply(initscript.classLoader.loadClass(pluginClassName))
200-
} finally {
201-
if (oldValue == null) {
202-
System.clearProperty('gradle.enterprise.externally-applied')
203-
} else {
204-
System.setProperty('gradle.enterprise.externally-applied', oldValue)
205-
}
206-
}
207-
}

0 commit comments

Comments
 (0)