forked from abayer/gradle-hpi-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract conditional test directory creation to LegacyWorkaroundsPlugin
- Loading branch information
Showing
3 changed files
with
31 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/groovy/org/jenkinsci/gradle/plugins/jpi/legacy/LegacyWorkaroundsPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jenkinsci.gradle.plugins.jpi.legacy | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import org.gradle.util.GradleVersion | ||
import org.jenkinsci.gradle.plugins.jpi.JpiExtension | ||
|
||
@CompileStatic | ||
class LegacyWorkaroundsPlugin implements Plugin<Project> { | ||
@Override | ||
void apply(Project project) { | ||
// workarounds for JENKINS-26331 | ||
project.tasks.named('test').configure { Task t -> | ||
def ext = project.extensions.getByType(JpiExtension) | ||
if (isBetween(ext.coreVersion, '1.545', '1.592')) { | ||
project.file('target').mkdirs() | ||
} | ||
} | ||
} | ||
|
||
private static boolean isBetween(String subject, String lowerBoundInclusive, String upperExclusive) { | ||
def current = GradleVersion.version(subject) | ||
def lower = GradleVersion.version(lowerBoundInclusive) | ||
def upper = GradleVersion.version(upperExclusive) | ||
current >= lower && current < upper | ||
} | ||
} |