-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
194 lines (171 loc) · 7.25 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
import org.omegat.documentation.DocbookHtml
import org.omegat.documentation.WhcTask
import org.omegat.documentation.StylesheetTask
import org.omegat.documentation.XIncludeTask
plugins {
id 'org.omegat.documentation'
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version "2.0.0"
}
repositories {
mavenCentral()
}
def documentRootDir = file('src/docs')
def styleRootDir = file('src/docs/xsl')
docConfig {
styleDir.set(styleRootDir)
docRoot.set(documentRootDir)
outputRoot.set(layout.buildDirectory.dir('docs/manual'))
}
tasks.register('manualHtmls') {
description = 'Build HTML manuals and zip for all languages. Requires container runtime.'
group = 'documentation'
}
def publications = []
def manualIndexXmls = fileTree(dir: 'src/docs', include: '**/OmegaTUsersManual_xinclude_full.xml')
manualIndexXmls.each { xml ->
def lang = xml.parentFile.name
def docbookInclude = tasks.register("docbookInclude${lang.capitalize()}", XIncludeTask) {
styleSheetFile.set(styleDir.file('passthrough.xsl'))
inputFile.set(file("${documentRootDir}/${lang}/OmegaTUsersManual_xinclude_full.xml"))
outputs.file file(layout.buildDirectory.dir("docs/manual/${lang}/xhtml5/_index.xml"))
}
def copyCss = tasks.register("copyCss${lang.capitalize()}", Copy) {
description 'Copy Images and CSS file to target'
into layout.buildDirectory.dir("docs/manual/${lang}")
from new File(documentRootDir, 'omegat.css')
}
def copyImages = tasks.register("copyImages${lang.capitalize()}", Copy) {
description 'Copy Images and CSS file to target'
into layout.buildDirectory.dir("docs/manual/${lang}/images/")
from new File(documentRootDir, "${lang}/images/")
}
def docbookHtml = tasks.register("docbookHtml${lang.capitalize()}", DocbookHtml) {
description 'Generate chunked HTML documentation'
language.set(lang)
inputFile.set(file("${documentRootDir}/${lang}/OmegaTUsersManual_xinclude_full.xml"))
mainOutputFile.set(outputRoot.get().file("${language.get()}/xhtml5/_index.html"))
styleSheetFile.set(styleDir.file("xhtml.xsl"))
inputs.dir(documentRootDir)
outputs.files(outputRoot.get().file("${language.get()}/xhtml5/_index.html"))
dependsOn(docbookInclude, copyImages, copyCss)
}
def whcToc = tasks.register("whcToc${lang.capitalize()}", StylesheetTask) {
description 'Generate whc header and index'
language.set(lang)
styleSheetFile.set(styleDir.file('whc-toc.xsl'))
inputFile.set(outputRoot.get().file("${lang}/xhtml5/_index.html"))
outputFile.set(outputRoot.get().file("${lang}/xhtml5/toc.xml"))
dependsOn(docbookHtml)
}
def whcIndex = tasks.register("whcIndex${lang.capitalize()}", StylesheetTask) {
description 'Generate whc header and index'
language.set(lang)
styleSheetFile.set(styleDir.file('whc-index.xsl'))
inputFile.set(outputRoot.get().file("${lang}/xhtml5/_index.html"))
outputFile.set(outputRoot.get().file("${lang}/xhtml5/index.html"))
dependsOn(docbookHtml, whcToc)
}
def whcHeader = tasks.register("whcHeader${lang.capitalize()}", StylesheetTask) {
description 'Generate whc header and index'
language.set(lang)
styleSheetFile.set(styleDir.file('whc-header.xsl'))
inputFile.set(outputRoot.file("${lang}/xhtml5/_index.xml"))
outputFile.set(outputRoot.get().file("${lang}/xhtml5/_header.xhtml"))
dependsOn(docbookHtml)
}
def buildDocumentTask = tasks.register("buildDocument${lang.capitalize()}", WhcTask) {
description 'Build whc contents'
tocFile.set(outputRoot.get().file("${lang}/xhtml5/toc.xml"))
inputFile.set(outputRoot.get().file("${lang}/xhtml5/index.html"))
outputDirectory.set(outputRoot.get().dir("${lang}"))
parameterList.set([
'layout', 'simple',
// 'user-header', "${language.get()}/xhtml5/_header.xhtml",
'--navigation-background-color', '#FDFDFD',
'--field-background-color', '#FDFDFD',
'--panel-background-color', '#FDFDFD',
'local-jquery', 'yes'
])
contentFiles.set(fileTree(dir: "${outputRoot.get()}/${lang}/xhtml5", include: '*.html', exclude: '_*'))
dependsOn(whcHeader, whcToc, whcIndex)
doLast {
project.delete(fileTree(dir: "${outputRoot.get()}/${lang}/xhtml5"))
project.delete(file("${outputRoot.get()}/${lang}/xhtml5"))
}
group('documentation')
}
manualHtmls.dependsOn buildDocumentTask
def zipTask= tasks.register("manualZip${lang.capitalize()}", Zip) {
from fileTree(dir: layout.buildDirectory.file("docs/manual/${lang}"))
exclude 'docs/manual/index.html'
from fileTree(dir: "src/docs/${lang}", include: '**/version*.properties')
archiveFileName = "${lang}.zip"
destinationDirectory = file(layout.buildDirectory.dir("docs/manuals/"))
dependsOn buildDocumentTask
}
assemble.dependsOn zipTask
def languageName = new Locale(lang).displayName
// Create a new publication for this language
def publication = publishing.publications.create("manual${lang.capitalize()}", MavenPublication) {
groupId = 'org.omegat'
artifactId = "omegat-manual-${lang}"
version = '6.1.0'
// Add the jar task to the publication
artifact(zipTask)
pom {
name = "OmegaT ${languageName} manual"
description = "OmegaT ${languageName} manual"
url = 'https://omegat.org'
scm {
connection = "scm:git:https://github.com/omegat-org/omegat-manual"
developerConnection = "scm:git:https://github.com/omegat-org/omegat-manual"
url = "https://github.com/omegat-org/omegat-manual"
}
licenses {
license {
name = 'The GNU General Public License, Version 3.0'
url = 'https://www.gnu.org/licenses/licenses/gpl-3.0.html'
}
}
developers {
developer {
id = 'omegat'
name = 'OmegaT Developers'
email = '[email protected]'
}
}
}
}
// Add the publication to the list
publications << publication
}
signing {
publications.each { publication ->
sign publication
}
if (!findProperty("signing.keyId")) {
useGpgCmd()
}
}
// Publish all the publications
publishing {
repositories {
maven {
url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials(PasswordCredentials) {
username = findProperty('ossrhUsername')
password = findProperty('ossrhPassword')
}
}
}
}
nexusPublishing.repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(findProperty('ossrhUsername') as String)
password.set(findProperty('ossrhPassword') as String)
}
}