aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src
diff options
context:
space:
mode:
authorSimon Ogorodnik <sem-oro@yandex.ru>2016-11-01 02:10:32 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-01 14:46:01 +0300
commit769701f99a1aefbc9d385c1938c9c7d3a7b2e38e (patch)
treec3ea4802d9e627c90870808aba9343eb224a114c /buildSrc/src
parent08bcaa257f7b48929af6ee29007dd6f0d7bb1b52 (diff)
downloaddokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.tar.gz
dokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.tar.bz2
dokka-769701f99a1aefbc9d385c1938c9c7d3a7b2e38e.zip
Total build refactoring, prepare for new development iteration
Removed old and useless build helpers Remove old .xml's from .idea and add .idea/shelf to .gitignore build-docs.xml fixed, dokka_version set to 0.9.10
Diffstat (limited to 'buildSrc/src')
-rw-r--r--buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy63
1 files changed, 63 insertions, 0 deletions
diff --git a/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy b/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy
new file mode 100644
index 00000000..db84fdc0
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy
@@ -0,0 +1,63 @@
+package org.jetbrains
+
+import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
+import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
+import groovy.xml.XmlUtil
+import org.apache.tools.zip.ZipEntry
+import org.apache.tools.zip.ZipOutputStream
+import org.gradle.api.file.FileTreeElement
+
+public class PluginXmlTransformer implements Transformer {
+ private Map<String, Node> transformedPluginXmlFiles = new HashMap<>();
+
+ @Override
+ boolean canTransformResource(FileTreeElement fileTreeElement) {
+ return fileTreeElement.relativePath.segments.contains("META-INF") && fileTreeElement.name.endsWith(".xml")
+ }
+
+ @Override
+ void transform(String path, InputStream inputStream, List<Relocator> relocators) {
+ System.out.println(path)
+ Node node = new XmlParser().parse(inputStream)
+ relocateXml(node, relocators)
+ transformedPluginXmlFiles.put(path, node)
+ }
+
+ @Override
+ boolean hasTransformedResource() {
+ return !transformedPluginXmlFiles.isEmpty()
+ }
+
+ @Override
+ void modifyOutputStream(ZipOutputStream zipOutputStream) {
+ for (Map.Entry<String, Node> entry : transformedPluginXmlFiles.entrySet()) {
+ zipOutputStream.putNextEntry(new ZipEntry(entry.key))
+ XmlUtil.serialize(entry.value, zipOutputStream)
+ }
+ }
+
+ private static void relocateXml(Node node, List<Relocator> relocators) {
+ Map attributes = node.attributes()
+ for (Map.Entry entry : attributes.entrySet()) {
+ entry.setValue(relocateClassName((String) entry.getValue(), relocators))
+ }
+ List<String> localText = node.localText()
+ if (localText.size() == 1) {
+ node.setValue(relocateClassName(localText[0], relocators))
+ }
+ node.children().each {
+ if (it instanceof Node) {
+ relocateXml((Node) it, relocators)
+ }
+ }
+ }
+
+ private static String relocateClassName(String className, List<Relocator> relocators) {
+ for (Relocator relocator : relocators) {
+ if (relocator.canRelocateClass(className)) {
+ return relocator.relocateClass(className)
+ }
+ }
+ return className
+ }
+} \ No newline at end of file