-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
129 lines (108 loc) · 3.78 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
plugins {
id 'groovy'
id 'maven-publish'
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '0.11.0'
}
apply plugin: 'java-gradle-plugin'
rootProject.group='com.github.ocroquette'
rootProject.version='2.7-SNAPSHOT'
java {
toolchain {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
pluginBundle {
website = 'https://github.com/ocroquette/gradle-extools'
vcsUrl = 'https://github.com/ocroquette/gradle-extools.git'
plugins {
extoolsPlugin {
id = 'com.github.ocroquette.extools'
displayName = 'External tools plugin'
description = 'A plugin that allows to download and use external tools like compilers or IDE automatically'
tags = ["tools", "compilers"]
// version = ''
}
}
}
dependencies {
implementation gradleApi()
testImplementation gradleTestKit()
testImplementation platform("org.spockframework:spock-bom:2.0-groovy-3.0")
testImplementation "org.spockframework:spock-core"
testImplementation "org.spockframework:spock-junit4" // for old JUnit 4 rules
testImplementation "com.github.tomakehurst:wiremock:2.10.1"
testImplementation "org.apache.commons:commons-text:1.1"
}
repositories {
mavenCentral()
}
test {
useJUnitPlatform()
}
task(zipDummyTools) {
description "Creates the ZIP files for the dummy tools used in the unit tests"
final resourceDir = new File(projectDir, "src/test/resources/extools")
final targetDir = new File(buildDir, "test/repo")
def toolIds = []
resourceDir.eachFileRecurse {
if ( it.name == "extools.conf" ) {
toolIds += resourceDir.toPath().relativize( it.toPath() ).toFile().parentFile.toString()
}
}
inputs.files(fileTree(resourceDir) {
exclude "**/*.zip"
})
outputs.files( toolIds.collect { new File(targetDir, it + ".zip") })
doLast {
toolIds.each { toolId ->
def srcDir = new File(resourceDir, toolId)
def destFile = new File(targetDir, "${toolId}.zip")
destFile.parentFile.mkdirs()
if(System.getProperty("os.name").toLowerCase().contains("windows")) {
ant.zip(destfile: destFile) {
fileset(dir: srcDir)
}
}
else {
// Use system zip to preserve permissions
project.exec {
commandLine "/usr/bin/zip", "--recurse-paths", "--quiet", destFile.absolutePath, "."
workingDir srcDir
}
}
}
}
}
test.dependsOn zipDummyTools
task doRelease {
doLast {
def buildGradle = new File("build.gradle")
def matcher = (buildGradle.text =~ /.*rootProject.version='([\d]+)\.([\d]+)-SNAPSHOT'/)
def major = Integer.parseInt(matcher[0][1])
def minor = Integer.parseInt(matcher[0][2])
def oldVersion = "${major}.${minor}"
def newVersion = "${major}.${minor+1}"
ant.replace(file: buildGradle, token: "rootProject.version='${oldVersion}-SNAPSHOT'", value: "rootProject.version='${oldVersion}'")
exec {
commandLine "git", "commit", "-a", "-m", "v${oldVersion}"
}
exec {
commandLine "./gradlew", "publishplugins"
}
exec {
commandLine "git", "tag", "v${oldVersion}"
}
ant.replace(file: buildGradle, token: "rootProject.version='${oldVersion}'", value: "rootProject.version='${newVersion}-SNAPSHOT'")
exec {
commandLine "git", "commit", "-a", "-m", "Started v${newVersion}"
}
exec {
commandLine "git", "push"
}
exec {
commandLine "git", "push", "--tags"
}
}
}