-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
129 lines (106 loc) · 3.14 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
129
// inspired by http://mrhaki.blogspot.com/2012/10/gradle-goodness-distribute-custom.html
// the Gradle samples also contain an example of how to do this
// Base plugin adds configuration
// support and build<Configuration>
// and upload<Configuration> tasks.
apply plugin: 'base'
apply plugin: 'maven'
group = 'org.kurron'
if ( project.properties.containsKey( 'project_version' ) )
{
logger.quiet "Using specifed project_version of $project_version"
status = 'release'
}
else
{
ext.project_version = '1.9.1-SNAPSHOT'
logger.quiet "project_version not specified. Using default version of $project_version"
status = 'integration'
}
project.version = project.project_version
ext {
gradleVersion = '1.9'
publicationUrl = "http://192.168.254.81:81/artifactory/mods-release-local"
publicationUsername = 'SVNBuild'
publicationPassword = 'Snoopy*09'
isSnapshot = version.endsWith('-SNAPSHOT')
}
// Extra configuration to store
// company Gradle ZIP artifact and
// use for uploading.
configurations {
companyGradle
}
if ( isSnapshot )
{
logger.quiet 'Snapshot revision detected. Nothing to do. Use -Pproject_version=1.2.3 to publish a new version.'
}
else
{
logger.quiet 'Release revision detected. Configuring for publication.'
uploadCompanyGradle {
repositories {
maven {
description 'Sandbox area of the repository to test publishing to'
url = publicationUrl
credentials {
username = publicationUsername
password = publicationPassword
}
}
}
uploadDescriptor = false
}
defaultTasks.add( 'uploadCompanyGradle' )
}
task wrapper(type: Wrapper) {
gradleVersion = gradleVersion
}
task downloadGradle(type: DownloadGradle) {
description 'Download Gradle version from Gradle distributions website'
gradleVersion project.gradleVersion
destinationDir file("$buildDir/gradle-downloads")
}
task companyGradleZip(type: Zip, dependsOn: downloadGradle) {
description 'Add extra files to company Gradle distribution'
// Name for company Gradle ZIP distribution.
baseName = 'company-gradle'
classifier = 'all'
from zipTree(downloadGradle.destinationFile)
into("${downloadGradle.distributionNameBase}") {
into('init.d') {
from "src/scripts/init.d"
}
into('config') {
from "src/rules"
}
}
}
artifacts {
companyGradle companyGradleZip
}
class DownloadGradle extends DefaultTask {
@Input
String gradleVersion
@Input
File destinationDir
@Input
String gradleDownloadBase = "http://services.gradle.org/distributions"
@TaskAction
doDownloadGradle() {
destinationFile.bytes = new URL(downloadUrl).bytes
}
String getDownloadUrl() {
"$gradleDownloadBase/$downloadFileName"
}
String getDistributionNameBase() {
"gradle-$gradleVersion"
}
String getDownloadFileName() {
"$distributionNameBase-all.zip"
}
@OutputFile
File getDestinationFile() {
new File(destinationDir, downloadFileName)
}
}