forked from gluck/gradle-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradle-plugin-base.gradle
110 lines (96 loc) · 2.74 KB
/
gradle-plugin-base.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
import org.gradle.api.Action;
import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler;
import org.gradle.api.internal.plugins.DslObject;
import org.gradle.api.publication.maven.internal.DefaultMavenRepositoryHandlerConvention;
import org.gradle.api.tasks.Upload;
apply plugin: 'eclipse'
apply plugin: 'groovy'
apply plugin: 'signing'
apply plugin: 'maven'
defaultTasks 'build'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile gradleApi()
compile localGroovy()
}
groovydoc {
source = sourceSets.main.allSource
}
task groovydocJar(type: Jar, dependsOn: groovydoc) {
classifier = 'javadoc'
from 'build/docs/groovydoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives jar
archives groovydocJar
archives sourcesJar
}
eclipse {
classpath {
file {
whenMerged {org.gradle.plugins.ide.eclipse.model.Classpath cp ->
String gradleHome = gradle.getGradleHomeDir().absolutePath.replace(File.separator, '/')
String gradleSrc = "${gradleHome}/src"
cp.entries.each {org.gradle.plugins.ide.eclipse.model.ClasspathEntry entry ->
if ((entry in org.gradle.plugins.ide.eclipse.model.AbstractLibrary) && (entry.library.file.name.startsWith('gradle-'))) {
entry.sourcePath = new org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory().fromPath(gradleSrc)
}
}
}
}
}
}
def customizePom(pom) {
pom.project {
name project.name
description project.description
}
if (project.ext.has('pom')) {
project.ext.pom(pom)
}
}
def setupUploadArchives(sonatypeRepositoryUrl) {
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
customizePom(pom)
beforeDeployment { MavenDeployment deployment ->
signing.signPom(deployment)
}
repository(url: sonatypeRepositoryUrl) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
}
}
}
}
allprojects {
afterEvaluate { project ->
if (project.hasProperty("release")) {
setupUploadArchives("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
} else {
project.version += "-SNAPSHOT"
if (project.hasProperty("snapshot")) {
setupUploadArchives("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
install {
repositories {
mavenInstaller {
customizePom(pom)
}
}
}
}
}