-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
204 lines (156 loc) · 5.03 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
apply plugin: 'groovy'
apply plugin: 'com.github.johnrengelman.shadow'
version='0.1.5'
ext.mrGadgetVersion = '0.3.1'
println "Using MrGadget version $mrGadgetVersion"
String build_location = 'LOCAL'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
}
}
if (build_location == 'LOCAL') {
println "USING LOCAL"
dependencies {
compile gradleApi()
compile "com.moksamedia:mrgadget:$project.ext.mrGadgetVersion:jar-with-dependencies" // *** don't forget about the stupid underscore instad of '.'
// in the group name when using GitHub
}
repositories {
mavenCentral()
flatDir {
dirs '../mrgadget/build/libs'
}
}
}
else if (build_location == 'GITHUB') {
println "USING GITHUB"
dependencies {
compile gradleApi()
compile 'com_moksamedia:mrgadget:$project.ext.mrGadgetVersion:jar-with-dependencies' // *** don't forget about the stupid underscore instad of '.'
// in the group name when using GitHub
}
repositories {
mavenCentral()
ivy {
url = 'https://raw.github.com/moksamedia/mrgadget/master/repo'
name = 'mrgadget-plugin'
layout 'pattern' , {
artifact "[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
}
}
}
}
jar {
manifest {
attributes("Implementation-Title": "MrGadget Gradle Plugin", "Implementation-Version": version, "MrGadgetVersion":project.ext.mrGadgetVersion)
}
}
shadowJar {
classifier 'jar-with-dependencies'
manifest {
attributes("Implementation-Title": "MrGadget Gradle Plugin", "Implementation-Version": version, "MrGadgetVersion":project.ext.mrGadgetVersion)
}
dependencies {
exclude(dependency('org.codehaus.groovy:groovy:.*'))
exclude(dependency('org.slf4j:slf4j-simple:.*'))
}
}
task generateApplyFromPlugin {
ext.classFile = file 'src/main/groovy/com/moksamedia/mrgadgetplugin/MrGadgetPlugin.groovy'
ext.srcFile = file 'mrgadget-plugin.src'
ext.outFile = file 'mrgadget-plugin.gradle'
inputs.files classFile, srcFile
outputs.file outFile
doLast {
// get the classes from the groovy file
String classesText = classFile.text
// remove the package line
classesText = classesText.replaceFirst('package com.moksamedia.mrgadgetplugin', '')
// insert the mrgadget version we are using
String headText = srcFile.text.replaceAll('MR_GADGET_VERSION', project.ext.mrGadgetVersion)
String noEditHeader = "// THIS FILE IS AUTOGENERATED -- DO NOT EDIT!\n\n"
// write the file
outFile.write(noEditHeader + headText + classesText + "\n")
}
}
build.dependsOn generateApplyFromPlugin
// copy jar and fatJar to base project directory so they will be in git (and on github for download)
task jarsToRepo << {
copy {
println "Copying ${jar.archiveName} to $projectDir/repo/com_moksamedia/mrgadget-plugin/$version"
from("$buildDir/libs/${jar.archiveName}")
into("$projectDir/repo/com_moksamedia/mrgadget-plugin/$version")
}
copy {
println "Copying ${shadowJar.archiveName} to $projectDir/repo/com_moksamedia/mrgadget-plugin/$version"
from("$buildDir/libs/${shadowJar.archiveName}")
into("$projectDir/repo/com_moksamedia/mrgadget-plugin/$version")
}
}
jarsToRepo.dependsOn shadowJar, jar
/*
* REQUIRED FOR OSS SONATYPE AND MAVEN CENTRAL DEPLOYMENT
*/
/*
apply plugin: 'maven'
apply plugin: 'signing'
group = 'com.moksamedia'
// create sources jar and javadoc jar (required for deployment to maven central)
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// add the jars as artifacts
artifacts {
archives sourcesJar
archives javadocJar
archives jar
archives fatJar
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project {
name 'MrGadget Gradle Plugin'
packaging 'jar'
description 'A Gradle plugin wrapper for MrGadget: a utility for deploying files to remote servers and executing commands on remote servers.'
url 'http://github.com/moksamedia/mrgadget-gradle-plugin'
scm {
url 'scm:[email protected]:moksamedia/mrgadget-gradle-plugin.git'
connection 'scm:[email protected]:moksamedia/mrgadget-gradle-plugin.git'
developerConnection 'scm:[email protected]:moksamedia/mrgadget-gradle-plugin.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'cantgetnosleep'
name 'Andrew Hughes'
}
}
}
}
}
}
*/