Skip to content

Commit

Permalink
JBDS-3929 apply the same content.xml transformations in content.jar a…
Browse files Browse the repository at this point in the history
…s in content.xml.xz
  • Loading branch information
nickboldt committed Jun 7, 2016
1 parent 37f0dc9 commit 5d98d44
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tycho-plugins/repository-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<artifactId>git-commit-id-plugin</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<version>1.5</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
}

/**
Expand Down

0 comments on commit 5d98d44

Please sign in to comment.