From 5d98d44e24fda71d817b0b935b7f42ecb2026d7d Mon Sep 17 00:00:00 2001 From: nickboldt Date: Tue, 7 Jun 2016 10:37:37 -0400 Subject: [PATCH] JBDS-3929 apply the same content.xml transformations in content.jar as in content.xml.xz --- tycho-plugins/repository-utils/pom.xml | 5 ++++ .../GenerateRepositoryFacadeMojo.java | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tycho-plugins/repository-utils/pom.xml b/tycho-plugins/repository-utils/pom.xml index f0d1719..cffe947 100644 --- a/tycho-plugins/repository-utils/pom.xml +++ b/tycho-plugins/repository-utils/pom.xml @@ -71,6 +71,11 @@ git-commit-id-plugin 2.1.13 + + org.tukaani + xz + 1.5 + diff --git a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java index 5bf189f..09c985b 100644 --- a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java +++ b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java @@ -10,6 +10,7 @@ ******************************************************************************/ package org.jboss.tools.tycho.sitegenerator; +import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -46,6 +47,7 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream; import org.apache.commons.io.IOUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; @@ -520,6 +522,29 @@ private void alterContentJar(File p2repository) throws FileNotFoundException, IO contentStream.close(); outContentStream.closeEntry(); outContentStream.close(); + + // JBDS-3929 overwrite the content.xml.xz file too + // see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=464614 + //getLog().debug("delete old content.xml.xz"); + FileUtils.forceDelete(new File(p2repository,"content.xml.xz")); + //getLog().debug("create content.xml from transformed XML"); + File contentXML = new File(p2repository, "content.xml"); + FileOutputStream outContentStreamXML = new FileOutputStream(contentXML); + StreamResult resultXML = new StreamResult(outContentStreamXML); + transformer.transform(source, resultXML); + outContentStreamXML.close(); + //getLog().debug("stream content.xml to content.xml.xz"); + BufferedInputStream in = new BufferedInputStream(new FileInputStream(contentXML)); + XZCompressorOutputStream out = new XZCompressorOutputStream(new FileOutputStream(new File(p2repository,"content.xml.xz"))); + final byte[] buffer = new byte[1024]; + int n = 0; + while (-1 != (n = in.read(buffer))) { + out.write(buffer, 0, n); + } + out.close(); + in.close(); + //getLog().debug("new content.xml.xz written; remove content.xml"); + FileUtils.forceDelete(new File(p2repository,"content.xml")); } /**