-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
249 lines (212 loc) · 7.75 KB
/
build.gradle
File metadata and controls
249 lines (212 loc) · 7.75 KB
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
import com.vanniktech.maven.publish.SonatypeHost
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://mauro-repository.com/libs-release-local" }
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'https://repo.gradle.org/gradle/libs-releases-local/' }
maven { url "https://mauro-repository.com/libs-snapshot-local" }
maven { url "https://mauro-repository.com/plugins-release-local" }
maven { url "https://mauro-repository.com/plugins-snapshot-local" }
}
}
plugins {
id 'groovy'
id 'java'
id 'antlr'
id 'maven-publish'
id "com.vanniktech.maven.publish" version "0.29.0"
id "com.github.hierynomus.license" version "0.16.1"
id 'codenarc'
id 'idea'
}
repositories {
mavenLocal()
maven {url "https://plugins.gradle.org/m2/"}
mavenCentral()
maven {url "https://mauro-repository.com/libs-release-local"}
maven {url "https://mauro-repository.com/libs-snapshot-local"}
maven {url "https://mauro-repository.com/plugins-release-local"}
}
// Define new "generation" sourceset for generating the dita library
sourceSets {
// Source is the generation code and the antlr generated source
generation {
groovy.srcDirs = ['src/generation/groovy', "${project.buildDir}/generated-src/generation/antlr"]
}
// Add the dita generated source into the main src
main {
groovy.srcDirs += ["${project.buildDir}/generated-src/main/dita"]
}
}
tasks.register('baseJar', Jar) {
archiveBaseName.set("dita-dsl-base")
from sourceSets.main.output
exclude 'org/maurodata/dita/elements/langref/learningtraining/**'
exclude 'org/maurodata/dita/elements/langref/technicalcontent/**'
}
license {
excludes(["${project.buildTreePath}/**",
"**/*.xml"])
header(project.file('NOTICE'))
}
// Setup the generation sourceset configurations to extend from the existing configurations
// Note that the antlr plugin adds a new configuration which is loaded into the compileClasspath
configurations {
generationImplementation.extendsFrom implementation
generationRuntimeOnly.extendsFrom runtimeOnly
}
test {
useJUnitPlatform()
}
jar{
exclude 'logback.*', 'log4j.*'
}
// Make sure we dont stamp addtl files with our license
license {
excludes([
'**/dita-ot-*/*',
'**/*.g4',
'**/org/maurodata/dita/ebnf/parser/*',
'**/*.properties'
])
}
// Customise the antlr grammer source to output to the "generation/antlr" directory
// Standard format of src dirs is "sourcesetname/codetype"
generateGrammarSource {
outputDirectory = project.file("${project.buildDir}/generated-src/generation/antlr")
maxHeapSize = "128m"
arguments += ['-visitor', '-no-listener']
}
tasks.register('replaceTabsWithSpaces'){
doLast{
tasks.generateGrammarSource.outputDirectory.traverse(type: groovy.io.FileType.FILES, nameFilter: ~/.*\.java$/){
it.write(it.text.replaceAll(/\t/,' '))
}
}
}
// Register a new task to generate the dita source into "main/dita" directory
tasks.register('generateDitaSource', JavaExec) {
ext.destDir = project.file('build/generated-src/main/dita')
outputs.dir destDir
classpath = sourceSets.generation.runtimeClasspath
mainClass = 'org.maurodata.dita.generation.DocumentationParser'
// arguments to pass to the application
argsString = 'build/generated-src/main/dita'
}
java {
withSourcesJar()
withJavadocJar()
}
// Ensure tasks are run in the correct order
// antlr grammar -> generation source set compiled -> dita source generated -> main code compiled
tasks.generateGrammarSource.finalizedBy 'replaceTabsWithSpaces'
tasks.compileGenerationJava.dependsOn 'generateGrammarSource','replaceTabsWithSpaces'
tasks.generateDitaSource.dependsOn 'generationClasses'
tasks.compileJava.dependsOn 'generateDitaSource'
tasks.sourcesJar.dependsOn 'generateDitaSource'
tasks.licenseGeneration.dependsOn "generateGrammarSource", "generateGenerationGrammarSource", "generateDitaSource"
tasks.licenseTest.dependsOn "generateGrammarSource", "generateGenerationGrammarSource", "generateDitaSource", "generateTestGrammarSource"
tasks.licenseMain.dependsOn "generateDitaSource"
codenarc {
configFile = rootProject.file("config/codenarc/codenarc.groovy")
ignoreFailures = true
}
codenarcGeneration {
compilationClasspath = sourceSets.generation.compileClasspath + sourceSets.generation.output
// Dont bother scanning the generated code, we've cleaned up most of the issues, the ones remaining are impossible to fix due to the source they're generated from
exclude '**/dita/elements/langref/**'
exclude '**/parser/**'
ignoreFailures = true
}
codenarcMain {
compilationClasspath = sourceSets.main.compileClasspath + sourceSets.main.output
// Dont bother scanning the generated code, we've cleaned up most of the issues, the ones remaining are impossible to fix due to the source they're generated from
exclude '**/dita/elements/langref/**'
exclude '**/parser/**'
ignoreFailures = true
}
afterEvaluate {
// Make sure intellij shows the build folder so we can see the generated code
// And add the src/main/antlr directory (source dir for antlr plugin) to the source listing so it looks right
idea.module{
sourceDirs << project.file('src/main/antlr')
}
jar {
manifest {
attributes(
"Class-Path": configurations.runtimeClasspath.collect {it.getName()}.join(' '))
}
}
// Make sure groovy tasks can compile
tasks.withType(GroovyCompile).configureEach {
configure(groovyOptions.forkOptions) {
memoryMaximumSize = '4g'
jvmArgs = ['-Xms512m', '-Xmx4g']
}
}
}
publishing {
repositories {
maven {
name = "MauroSnapshot"
url = "https://mauro-repository.com/libs-snapshot-local"
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
publications {
/* mavenJava(MavenPublication) {
groupId = 'org.maurodata'
artifactId = 'dita-dsl'
version = "2.0.0-SNAPSHOT"
from components.java
}
*/ // new lite publication (dita-dsl-base)
base(MavenPublication) {
groupId = 'org.maurodata'
artifactId = 'dita-dsl-base'
version = "2.0.0-SNAPSHOT"
artifact(tasks.named("baseJar"))
}
}
}
mavenPublishing {
configure(new JavaLibrary(new JavadocJar.None(), true))
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)
signAllPublications()
//coordinates(group, rootProject.name, version)
pom {
name = 'DITA Groovy DSL'
description = 'Provides a MarkupBuilder for editing DITA XML from Groovy code'
url = "https://github.com/MauroDataMapper/dita-groovy-dsl"
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'jamesrwelch'
name = 'James Welch'
email = 'james.welch@bdi.ox.ac.uk'
}
}
scm {
url = "https://github.com/MauroDataMapper/dita-groovy-dsl"
}
}
}
tasks.withType(PublishToMavenRepository).configureEach {
mustRunAfter(tasks.withType(Sign)) // ensures signing is finished first
}
tasks.withType(PublishToMavenLocal).configureEach {
mustRunAfter(tasks.withType(Sign)) // ensures signing is finished first
}
apply from: 'dependencies.gradle'