This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
179 lines (150 loc) · 6.92 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
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge', name: 'srgutils', version: '0.4.1'
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: forgegradle_version
}
}
apply plugin: 'java'
import fcw.tasks.*
import fcw.DocUtils
import java.util.stream.Collectors
println "MC: ${minecraft_version}, Forge: ${forge_version}, MCP mappings: ${mappings_version} on channel ${mappings_channel}"
allprojects {
ext {
// Defines dependencies which will be exported into the workspace for the javadocs
SOURCES = [
"forge": "net.minecraftforge:forge:"
] as LinkedHashMap
DOCS_DIR = rootProject.file('src/docs')
DOC_FILE_EXTENSION = '.json'
}
}
task writeDocs(group: 'javadocs') {
description 'Write out doc files for all source sets'
}
task clearSources(group: 'javadocs') {
description 'Clears source folder for all source sets'
}
task copySources(group: 'javadocs') {
shouldRunAfter clearSources
description 'Copy sources from respective artifacts for all source sets'
}
task removeComments(group: 'javadocs') {
shouldRunAfter copySources
description 'Remove javadoc comments from source files for all source sets'
}
task applyDocs(group: 'javadocs', dependsOn: removeComments) {
description 'Apply javadocs from doc files for all source sets'
}
task setup(group: 'javadocs', dependsOn: [clearSources, copySources, applyDocs]) {
description 'Sets up the javadocs workspace'
}
task assembleJavadocs(type: Javadoc, group: 'javadocs') {
description 'Assembles the javadocs from all source sets'
destinationDir project.file('out')
title "FCW: Javadocs"
//source project.files('src/extra/')
javadocTool = javaToolchains.javadocToolFor {
languageVersion = JavaLanguageVersion.of(15)
}
def opt = options.header("Forge (${minecraft_version}-${forge_version}; mappings ${mappings_channel}-${mappings_version})")
opt.docTitle "FCW: Javadocs for Forge ${minecraft_version}-${forge_version}"
opt.windowTitle "FCW: Javadocs [${minecraft_version}]"
opt.groupsFile project.file("src/groups.txt")
opt.optionFiles project.file("src/options.txt")
opt.stylesheetFile project.file("src/style.css")
opt.docFilesSubDirs true
doLast {
project.copy {
from project.file("src/extra")
into project.file('out')
}
}
}
project(':workspace') {
apply plugin: 'net.minecraftforge.gradle'
minecraft {
mappings channel: mappings_channel, version: mappings_version
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
}
afterEvaluate {
def mcDeps = configurations.minecraft.incoming.resolutionResult.allDependencies.collect { it.selected.id }
SOURCES.entrySet().stream().forEach { sourceEntry ->
String sourceSetName = sourceEntry.key
def pattern = sourceEntry.value
def matchingDeps = mcDeps.stream().filter { it.displayName.startsWith pattern }.collect(Collectors.toSet())
if (matchingDeps.size() == 0) {
logger.warn("Source pattern '{} -> {}' has no matching dependencies, skipping", sourceSetName, pattern)
return
} else if (matchingDeps.size() > 1) {
logger.warn("Source '{} -> {}' has more than 1 dependency, skipping: {}", sourceSetName, pattern, matchingDeps)
return
}
def matchingDep = matchingDeps[0]
logger.lifecycle("- Source set '{}' for artifact '{}'", sourceSetName, matchingDep)
SourceSet sourceSet = sourceSets.create(sourceSetName)
def config = configurations.maybeCreate(sourceSet.implementationConfigurationName)
config.canBeResolved(true)
configurations.minecraft.dependencies.forEach {
dependencies.add(sourceSet.implementationConfigurationName, it)
}
assembleJavadocs {
classpath += configurations.minecraft.incoming.files
source DocUtils.filter(sourceSet.java.srcDirs[0], DOCS_DIR, DOC_FILE_EXTENSION)
}
def writeDocsTask = project.getTasks().create("write" + sourceSetName.capitalize() + "Docs", MakeDocs.class)
writeDocs.dependsOn writeDocsTask
writeDocsTask.configure {
it.group 'javadocs'
it.description "Write out doc files for source set '${sourceSetName}'"
it.docsDir = DOCS_DIR
it.configuration = config
it.sourcesDir = sourceSet.java.srcDirs[0]
it.docFileExtension = DOC_FILE_EXTENSION
}
def clearSourcesTask = project.getTasks().create("clear" + sourceSetName.capitalize() + "Sources", Delete.class)
clearSources.dependsOn clearSourcesTask
clearSourcesTask.configure {
it.group 'javadocs'
it.description "Clears source folder for source set '${sourceSetName}'"
it.delete sourceSet.java.srcDirs[0]
}
def copySourcesTask = project.getTasks().create("copy" + sourceSetName.capitalize() + "Sources", CopySources.class)
copySources.dependsOn copySourcesTask
copySourcesTask.configure {
it.group 'javadocs'
it.description "Copy sources from artifact ${matchingDep} for source set '${sourceSetName}'"
it.shouldRunAfter clearSourcesTask
it.artifact = matchingDep
it.destDir = sourceSet.java.srcDirs[0]
}
def removeCommentsTask = project.getTasks().create("remove" + sourceSetName.capitalize() + "Comments", RemoveComments.class)
removeComments.dependsOn removeCommentsTask
removeCommentsTask.configure {
it.group 'javadocs'
it.description "Remove javadoc comments from source files for source set '${sourceSetName}'"
it.shouldRunAfter copySourcesTask
it.sourcesDir = sourceSet.java.srcDirs[0]
it.configuration = config
}
def applyDocsTask = project.getTasks().create("apply" + sourceSetName.capitalize() + "Docs", ApplyDocs.class)
applyDocs.dependsOn applyDocsTask
applyDocsTask.configure {
it.group 'javadocs'
it.description "Apply javadocs from doc files for source set '${sourceSetName}'"
it.dependsOn removeCommentsTask
it.docsDir = DOCS_DIR
it.configuration = config
it.sourcesDir = sourceSet.java.srcDirs[0]
it.docFileExtension = DOC_FILE_EXTENSION
it.pkgInfoTemplate = rootProject.file('src/package-info-template.java')
}
}
}
}