From e4635a6a36ec2ad9764293a06e90b793bbbc4efd Mon Sep 17 00:00:00 2001 From: nickboldt Date: Tue, 7 Jun 2016 10:54:35 -0400 Subject: [PATCH] JBDS-3929 apply the same artifacts.xml transformations in artifacts.jar as in artifacts.xml.xz --- .../GenerateRepositoryFacadeMojo.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 09c985b..ea75737 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 @@ -604,6 +604,30 @@ private void addP2Stats(File p2repository) throws FileNotFoundException, IOExcep contentStream.close(); outContentStream.closeEntry(); outContentStream.close(); + + // JBDS-3929 overwrite the artifacts.xml.xz file too + // see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=464614 + //getLog().debug("delete old artifacts.xml.xz"); + FileUtils.forceDelete(new File(p2repository,"artifacts.xml.xz")); + //getLog().debug("create artifacts.xml from transformed XML"); + File artifactsXML = new File(p2repository, "artifacts.xml"); + FileOutputStream outartifactsStreamXML = new FileOutputStream(artifactsXML); + StreamResult resultXML = new StreamResult(outartifactsStreamXML); + transformer.transform(source, resultXML); + outartifactsStreamXML.close(); + //getLog().debug("stream artifacts.xml to artifacts.xml.xz"); + BufferedInputStream in = new BufferedInputStream(new FileInputStream(artifactsXML)); + XZCompressorOutputStream out = new XZCompressorOutputStream(new FileOutputStream(new File(p2repository,"artifacts.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 artifacts.xml.xz written; remove artifacts.xml"); + FileUtils.forceDelete(new File(p2repository,"artifacts.xml")); + } private void alterIndexFile(File outputSite) throws FileNotFoundException, IOException {