-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.gradle
170 lines (147 loc) · 4.93 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
plugins {
id 'java-base'
id 'jacoco'
id 'com.github.jk1.dependency-license-report'
id "com.github.ben-manes.versions"
id 'biz.aQute.bnd.builder' apply false
id 'maven-publish'
}
ext {
leafProjects = subprojects.findAll { p -> p.subprojects.empty }
javaProjects = leafProjects - project( ':runtime' )
apiProjects = rootProject.subprojects.findAll { project -> project.name.endsWith( '-api' ) }
}
allprojects {
group = 'com.enonic.xp'
afterEvaluate {
def subProject = it
def hasPublishPlugins = subProject.plugins.hasPlugin( PublishingPlugin ) && subProject.plugins.hasPlugin( MavenPublishPlugin )
def hasJavaPlugin = subProject.plugins.hasPlugin( JavaPlugin )
if ( !hasPublishPlugins )
{
return
}
if ( hasJavaPlugin )
{
javadoc {
options {
quiet()
encoding( 'UTF-8' )
}
}
subProject.publishing {
publications {
mavenJava( MavenPublication ) {
from components.java
if ( subProject.name.startsWith( 'lib-' ) || subProject.name.endsWith( '-api' ) )
{
java {
withJavadocJar()
withSourcesJar()
}
customizePomXml( subProject, it )
}
}
}
}
}
subProject.publishing {
repositories {
maven {
credentials {
username rootProject.findProperty( 'repoUser' )
password rootProject.findProperty( 'repoPassword' )
}
name "public"
url "https://repo.enonic.com/${rootProject.version.endsWith( 'SNAPSHOT' ) ? 'snapshot' : 'public'}"
}
}
}
}
}
def customizePomXml( subProject, mavenJava )
{
mavenJava.pom {
name = subProject.name
description = subProject.name
url = "https://github.com/enonic/xp"
licenses {
license {
def isLibrary = subProject.name.startsWith( 'lib-' )
name = "${isLibrary ? 'The Apache Software License, Version 2.0' : 'GNU General Public License, Version 3.0'}"
url = "https://github.com/enonic/xp/blob/master/${isLibrary ? 'LICENSE_AL.txt' : 'LICENSE.txt'}"
}
}
developers {
developer {
id = 'developers'
name = 'Enonic developers'
email = '[email protected]'
}
}
scm {
connection = "scm:git:[email protected]:enonic/xp.git"
developerConnection = "scm:git:[email protected]:enonic/xp.git"
url = "https://github.com/enonic/xp"
}
}
}
configure( javaProjects ) {
apply from: "$rootDir/gradle/java.gradle"
}
task ci {
description = 'Builds and generates coverage report.'
dependsOn = ['build', 'jacocoMergedReport']
}
task jacocoMergedReport( type: JacocoReport ) {
group = 'verification'
description = 'Generates a merged report all sub-projects.'
def projects = subprojects.findAll { it.plugins.hasPlugin( JacocoPlugin ) }
dependsOn projects*.jacocoTestReport
sourceDirectories.setFrom( projects*.sourceSets*.main*.allSource )
classDirectories.setFrom( files( projects*.sourceSets*.main*.output ) )
executionData.setFrom(files(projects*.jacocoTestReport*.executionData))
reports {
html.required = true
xml.required = true
csv.required = false
}
}
def isNonStable = { String version ->
return ['alpha', 'beta', '-rc', '-m', '-b'].any { it -> version.toLowerCase().contains(it) }
}
dependencyUpdates {
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
task javadoc( type: Javadoc, group: 'documentation' ) {
title = "Enonic XP API ${version}"
options {
links 'https://docs.oracle.com/en/java/javase/11/docs/api/'
links 'https://www.javadoc.io/doc/com.google.guava/guava/26.0-jre'
quiet()
encoding( 'UTF-8' )
}
apiProjects.each { project ->
project.tasks.withType( Javadoc ).each { javadocTask ->
source += javadocTask.source
classpath += javadocTask.classpath
excludes += javadocTask.excludes
includes += javadocTask.includes
}
}
}
task javadocZip( type: Zip ) {
from javadoc
archiveFileName = "${project.name}-${project.version}-javadoc.zip"
destinationDirectory = project.distsDirectory
archiveClassifier.set( 'javadoc' )
}
publishing.publications {
mavenDocs( MavenPublication ) {
artifact( javadocZip ) {
artifactId = 'docs'
}
}
}