Skip to content

Commit 071aed0

Browse files
committed
Implemented additional xz compression of artifacts.xml
1 parent 227abc9 commit 071aed0

File tree

5 files changed

+55
-12
lines changed

5 files changed

+55
-12
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ osspub {
5858
name 'Lsp4j'
5959
group 'technology.lsp4j'
6060
url "http://services.typefox.io/open-source/jenkins/job/lsp4j/job/${osspub.branch}/lastStableBuild/artifact/build/lsp4j.p2-repository-${osspub.version}.zip"
61+
deployPath 'lsp4j'
6162
namespace 'org.eclipse.lsp4j'
6263
referenceFeature 'org.eclipse.lsp4j.sdk'
6364
}

buildSrc/.settings/org.eclipse.buildship.core.prefs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
build.commands=org.eclipse.jdt.core.javabuilder,org.eclipse.xtext.ui.shared.xtextBuilder
22
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
33
connection.project.dir=
4+
containers=org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6/
45
derived.resources=.gradle,build
56
eclipse.preferences.version=1
67
natures=org.eclipse.jdt.core.javanature,org.eclipse.xtext.ui.shared.xtextNature

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ dependencies {
3535
compile "org.sonatype.plexus:plexus-cipher:1.4"
3636
compile "org.sonatype.plexus:plexus-sec-dispatcher:1.3"
3737
compile "pw.prok:download:3.1.3"
38+
compile "org.tukaani:xz:1.6"
3839
}

buildSrc/src/main/java/io/typefox/publishing/EclipsePublishing.xtend

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ package io.typefox.publishing
1010
import com.google.common.collect.AbstractIterator
1111
import com.google.common.io.Files
1212
import java.io.File
13+
import java.io.FileInputStream
1314
import java.io.FileOutputStream
1415
import java.io.FilenameFilter
1516
import java.io.IOException
17+
import java.io.InputStream
18+
import java.io.OutputStream
1619
import java.nio.charset.Charset
1720
import java.util.concurrent.Callable
1821
import java.util.jar.JarFile
@@ -29,6 +32,8 @@ import org.gradle.api.Project
2932
import org.gradle.api.tasks.Copy
3033
import org.gradle.api.tasks.Delete
3134
import org.gradle.api.tasks.bundling.Zip
35+
import org.tukaani.xz.LZMA2Options
36+
import org.tukaani.xz.XZOutputStream
3237
import org.w3c.dom.Element
3338
import pw.prok.download.Download
3439

@@ -128,7 +133,7 @@ class EclipsePublishing {
128133
from = '''«buildDir»/p2-«repoName.toLowerCase»/repository-unsigned'''
129134
into = '''«rootDir»/build-result/p2.repository'''
130135
if (osspub.signJars) {
131-
exclude('**/artifacts.jar')
136+
exclude('**/artifacts.*')
132137
for (namespace : repository.namespaces) {
133138
exclude('''**/«namespace»*.jar''')
134139
}
@@ -195,7 +200,7 @@ class EclipsePublishing {
195200
packages.base=downloads
196201
tests.base=test-results
197202
group.owner=«repository.group»
198-
downloads.area=/home/data/httpd/download.eclipse.org/«repository.group?.replace('.', '/')»/
203+
downloads.area=/home/data/httpd/download.eclipse.org/«repository.deployPath ?: repository.group?.replace('.', '/')»/
199204
'''
200205

201206
private def getBuildPrefix() {
@@ -238,15 +243,27 @@ class EclipsePublishing {
238243
}
239244

240245
private def updateArtifactsXml(String sourceDir, String destDir) {
246+
var InputStream sourceStream
241247
var JarFile sourceJar
248+
var OutputStream targetStream
242249
var JarOutputStream targetJar
250+
var XZOutputStream targetXz
243251
try {
244-
sourceJar = new JarFile('''«sourceDir»/artifacts.jar''')
245-
val artifactsEntry = sourceJar.getEntry('artifacts.xml')
246-
if (artifactsEntry === null)
247-
throw new GradleException('artifacts.jar does not contain artifacts.xml')
252+
val artifactsXmlFile = new File('''«sourceDir»/artifacts.xml''')
253+
val artifactsJarFile = new File('''«sourceDir»/artifacts.jar''')
254+
if (artifactsXmlFile.exists) {
255+
sourceStream = new FileInputStream(artifactsXmlFile)
256+
} else if (artifactsJarFile.exists) {
257+
sourceJar = new JarFile(artifactsJarFile)
258+
val artifactsEntry = sourceJar.getEntry('artifacts.xml')
259+
if (artifactsEntry === null)
260+
throw new GradleException('P2 repository: artifacts.jar does not contain artifacts.xml')
261+
sourceStream = sourceJar.getInputStream(artifactsEntry)
262+
} else {
263+
throw new GradleException('P2 repository does not contain artifacts.xml or artifacts.jar')
264+
}
248265
val builder = DocumentBuilderFactory.newInstance.newDocumentBuilder
249-
val document = builder.parse(sourceJar.getInputStream(artifactsEntry))
266+
val document = builder.parse(sourceStream)
250267
val xmlRoot = document.documentElement
251268
if (xmlRoot.tagName == 'repository') {
252269
for (artifacts : xmlRoot.getElements('artifacts')) {
@@ -268,15 +285,32 @@ class EclipsePublishing {
268285
}
269286
}
270287

271-
targetJar = new JarOutputStream(new FileOutputStream('''«destDir»/artifacts.jar'''))
272-
targetJar.putNextEntry(new ZipEntry('artifacts.xml'))
273288
val transformer = TransformerFactory.newInstance.newTransformer
274-
transformer.transform(new DOMSource(document), new StreamResult(targetJar))
275-
targetJar.closeEntry()
289+
if (artifactsXmlFile.exists) {
290+
targetStream = new FileOutputStream('''«destDir»/artifacts.xml''')
291+
transformer.transform(new DOMSource(document), new StreamResult(targetStream))
292+
}
293+
294+
if (artifactsJarFile.exists) {
295+
targetJar = new JarOutputStream(new FileOutputStream('''«destDir»/artifacts.jar'''))
296+
targetJar.putNextEntry(new ZipEntry('artifacts.xml'))
297+
transformer.transform(new DOMSource(document), new StreamResult(targetJar))
298+
targetJar.closeEntry()
299+
}
300+
301+
val artifactsXmlXzFile = new File('''«sourceDir»/artifacts.xml.xz''')
302+
if (artifactsXmlXzFile.exists) {
303+
val options = new LZMA2Options
304+
targetXz = new XZOutputStream(new FileOutputStream('''«destDir»/artifacts.xml.xz'''), options)
305+
transformer.transform(new DOMSource(document), new StreamResult(targetXz))
306+
}
276307
} finally {
277308
try {
278-
sourceJar?.close()
309+
targetXz?.close()
279310
targetJar?.close()
311+
targetStream?.close()
312+
sourceJar?.close()
313+
sourceStream?.close()
280314
} catch (IOException e) {}
281315
}
282316
}

buildSrc/src/main/java/io/typefox/publishing/P2Repository.xtend

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class P2Repository {
1919

2020
String url
2121

22+
String deployPath
23+
2224
val List<String> namespaces = newArrayList
2325

2426
String referenceFeature
@@ -35,6 +37,10 @@ class P2Repository {
3537
this.url = input.toString
3638
}
3739

40+
def void deployPath(Object input) {
41+
this.deployPath = input.toString
42+
}
43+
3844
def void namespace(Object input) {
3945
this.namespaces += input.toString
4046
}

0 commit comments

Comments
 (0)