Created
August 18, 2020 13:42
-
-
Save serbaniuliuscezar/21964b3fc82059b87b993cdea7879289 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
val ansiColorPluginVersion: String = "0.6.2" | |
val jenkinsCoreVersion: String = "2.231" | |
val jobDslVersion: String = "1.77" | |
val implementation by configurations | |
val testImplementation by configurations | |
plugins { | |
id("java-library") | |
id("java") | |
id("groovy") | |
id("distribution") | |
id("codenarc") | |
id("com.adarshr.test-logger").version("2.0.0") | |
} | |
repositories { | |
mavenCentral() | |
maven { | |
name = "Jenkins Maven Repo" | |
url = uri("https://repo.jenkins-ci.org/releases/") | |
} | |
maven { | |
name = "Maven repository" | |
url = uri("https://mvnrepository.com/artifact/") | |
} | |
maven { | |
name = "Jenkins public Repo" | |
url = uri("https://repo.jenkins-ci.org/public/") | |
} | |
maven { | |
name = "Nuxeo maven repo" | |
url = uri("https://maven-eu.nuxeo.org/nexus/content/repositories/public-releases/") | |
} | |
maven { | |
name = "Netbeans Repo" | |
url = uri("https://bits.netbeans.org/maven2/") | |
} | |
} | |
// Exclude buggy Xalan dependency; this way the JRE default TransformerFactory is used. | |
// The xalan pulled in by htmlunit does not properly deal with spaces folder / job names. | |
configurations { | |
all { | |
testPlugins {} | |
exclude("xalan") | |
exclude("xerces") | |
} | |
} | |
dependencies { | |
implementation("org.codehaus.groovy:groovy-all:2.5.7") | |
implementation("org.yaml:snakeyaml:1.25") | |
implementation("org.jenkins-ci.main:jenkins-core:${jenkinsCoreVersion}") | |
implementation("org.jenkins-ci.plugins:job-dsl-core:${jobDslVersion}") | |
testImplementation("org.jenkins-ci.main:jenkins-war:${jenkinsCoreVersion}") | |
testImplementation("org.jenkins-ci.main:jenkins-war:${jenkinsCoreVersion}@war") | |
// Plugins to install in test instance. | |
testPlugins("org.jenkins-ci.plugins:ghprb:1.39.0") | |
testPlugins("com.coravy.hudson.plugins.github:github:1.29.3") | |
} | |
tasks.register("resolvetestPluginstype", Copy::class) { | |
from(configurations.testPlugins()) | |
into new File(sourceSets.test.output.resourcesDir, "test-dependencies") | |
include("*.hpi") | |
include("*.jpi") | |
LinkedHashMap(mapping) = [:] | |
doFirst { | |
configurations.testPlugins.resolvedConfiguration.resolvedArtifacts.each { | |
mapping[it.file.name] = "${it.name}.${it.extension}") | |
} | |
} | |
rename { mapping[it] } | |
doLast { | |
List<String> baseNames = source *.name.collect { mapping[it] }.collect { it[0..it.lastIndexOf(".") - 1] } | |
new File (destinationDir, "index").setText(baseNames.join("\n"), "UTF-8") | |
} | |
} | |
tasks.register("test") { | |
dependsOn("resolveTestPlugins") | |
inputs.files(sourceSets.main.groovy.srcDirs) | |
systemProperty = "buildDirectory", project.buildDir.absolutePath | |
} | |
tasks.register("packageZip", Zip::class) { | |
from(".") | |
include("**/*") | |
exclude("**/.gradle/**") | |
exclude("**/out/**") | |
exclude("**/build/**") | |
val archiveFileName = provider { | |
"builder.zip" | |
} | |
val destinationDirectory = DirectoryProperty("./build/archive/") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment