Author: mickael_istria
Date: 2012-10-11 06:27:33 -0400 (Thu, 11 Oct 2012)
New Revision: 44426
Modified:
trunk/build/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java
trunk/build/tycho-plugins/repository-utils/src/main/resources/index.html
trunk/build/tycho-plugins/repository-utils/src/main/resources/web/site.css
Log:
JBIDE-12660: Easier customization
Modified:
trunk/build/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java
===================================================================
---
trunk/build/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java 2012-10-11
10:27:06 UTC (rev 44425)
+++
trunk/build/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java 2012-10-11
10:27:33 UTC (rev 44426)
@@ -66,7 +66,7 @@
* Generates a JBoss-friendly facade and files for this p2 repo
*
* @goal generate-repository-facade
- *
+ *
* @phase package
*/
public class GenerateRepositoryFacadeMojo extends AbstractTychoPackagingMojo {
@@ -81,26 +81,26 @@
* @readonly
*/
private MavenProject project;
-
+
/**
* Additional symbols, to replace in files
*
* @parameter
*/
private Map<String, String> symbols;
-
+
/**
* template folder for HTML contents
* @parameter
*/
private File siteTemplateFolder;
-
+
/**
* Additional sites to add to repo associateSites
- * @parameter
+ * @parameter
*/
private List<String> associateSites;
-
+
/**
* name of the file in ${siteTemplateFolder} to use as template for index.html
* @parameter default-value="index.html"
@@ -113,12 +113,12 @@
return;
}
- if (symbols == null) {
- symbols = new HashMap<String, String>();
+ if (this.symbols == null) {
+ this.symbols = new HashMap<String, String>();
}
// TODO populate default symbols: ${update.site.name} &
${update.site.description}
-
- File outputRepository = new File(project.getBuild().getDirectory(),
"repository");
+
+ File outputRepository = new File(this.project.getBuild().getDirectory(),
"repository");
File outputSiteXml = generateSiteXml(outputRepository);
generateSiteProperties(outputRepository, outputSiteXml);
generateJBossToolsDirectoryXml(outputRepository);
@@ -128,8 +128,8 @@
} catch (Exception ex) {
throw new MojoExecutionException("Error while altering
content.jar",ex);
}
-
-
+
+
File repoZipFile = new File(project.getBuild().getDirectory(),
project.getArtifactId() + "-" + project.getVersion() + ".zip");
repoZipFile.delete();
try {
@@ -141,7 +141,7 @@
} catch (Exception ex) {
throw new MojoExecutionException("Could not create " +
repoZipFile.getName(), ex);
}
-
+
}
private void generateWebStuff(File outputRepository, File outputSiteXml)
@@ -160,8 +160,8 @@
} catch (Exception ex) {
throw new MojoExecutionException("Error occured while generating
'site.properties'", ex);
}
-
-
+
+
try {
copyTemplateResources(outputRepository);
} catch (Exception ex) {
@@ -219,7 +219,7 @@
} catch (Exception ex) {
throw new MojoExecutionException("Error occured while generating
'site.properties'", ex);
}
-
+
try {
copyTemplateResources(outputRepository);
} catch (Exception ex) {
@@ -234,7 +234,7 @@
if (!categoryFile.isFile()) {
throw new MojoExecutionException("Missing 'category.xml
file'");
}
-
+
UpdateSite site = null;
try {
site = UpdateSite.read(categoryFile);
@@ -309,7 +309,7 @@
done = true;
}
}
- // .close and .closeEntry raise exception:
+ // .close and .closeEntry raise exception:
//
https://issues.apache.org/bugzilla/show_bug.cgi?id=3862
ZipOutputStream outContentStream = new ZipOutputStream(new
FileOutputStream(contentJar));
ZipEntry contentXmlEntry = new ZipEntry("content.xml");
@@ -318,16 +318,16 @@
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(contentDoc);
StreamResult result = new StreamResult(outContentStream);
- transformer.transform(source, result);
+ transformer.transform(source, result);
outContentStream.closeEntry();
outContentStream.close();
}
private void alterIndexFile(File outputSite) throws FileNotFoundException, IOException
{
- File templateFile = new File(outputSite, indexName);
+ File templateFile = new File(outputSite, this.indexName);
FileInputStream fis = new FileInputStream(templateFile);
String htmlFile = IOUtil.toString(fis, "UTF-8");
- for (Entry<String, String> entry : symbols.entrySet()) {
+ for (Entry<String, String> entry : this.symbols.entrySet()) {
String key = entry.getKey();
if (!key.startsWith("${")) {
key = "${" + key + "}";
@@ -336,17 +336,25 @@
}
FileOutputStream out = new FileOutputStream(templateFile);
out.write(htmlFile.getBytes("UTF-8"));
+ fis.close();
out.close();
}
-
- private void copyTemplateResources(File outputSite) throws IOException {
- if (siteTemplateFolder != null) {
- FileUtils.copyDirectory(siteTemplateFolder, outputSite);
+
+ private void copyTemplateResources(File outputSite) throws IOException,
MojoExecutionException {
+ if (this.siteTemplateFolder != null) {
+ if (!this.siteTemplateFolder.isDirectory()) {
+ throw new MojoExecutionException("'siteTemplateFolder' not correctly
set. " + this.siteTemplateFolder.getAbsolutePath() + " is not a
directory");
+ }
+ FileUtils.copyDirectoryStructure(this.siteTemplateFolder, outputSite);
+ if (!new File(this.siteTemplateFolder, this.indexName).isFile()) {
+ // copy default index
+ InputStream indexStream = getClass().getResourceAsStream("/index.html");
+ FileUtils.copyStreamToFile(new RawInputStreamFacade(indexStream), new
File(outputSite, this.indexName));
+ indexStream.close();
+ }
} else {
- // load from resources
InputStream indexStream = getClass().getResourceAsStream("/index.html");
- indexName = "index.html";
- FileUtils.copyStreamToFile(new RawInputStreamFacade(indexStream), new File(outputSite,
"index.html"));
+ FileUtils.copyStreamToFile(new RawInputStreamFacade(indexStream), new File(outputSite,
this.indexName));
indexStream.close();
File webFolder = new File(outputSite, "web");
if (!webFolder.exists()) {
Modified: trunk/build/tycho-plugins/repository-utils/src/main/resources/index.html
===================================================================
--- trunk/build/tycho-plugins/repository-utils/src/main/resources/index.html 2012-10-11
10:27:06 UTC (rev 44425)
+++ trunk/build/tycho-plugins/repository-utils/src/main/resources/index.html 2012-10-11
10:27:33 UTC (rev 44426)
@@ -1,17 +1,13 @@
<html>
<head>
<title>${update.site.name} - ${update.site.description} Update
Site${update.site.version}</title>
-<style>
-@import
url("http://download.jboss.org/jbosstools/updates/web/site.css");
-</style>
+<link rel="stylesheet" type="text/css"
href="web/site.css">
</head>
<body marginheight="0" marginwidth="0" leftmargin="0"
topmargin="0">
<center>
-<table marginheight="0" marginwidth="0" leftmargin="0"
topmargin="0"
- cellspacing="0" cellpadding="0" width="920"
class="bodyText">
+<table cellspacing="0" cellpadding="0"
class="table">
<tr>
- <td colspan="3"><img
-
src="https://www.jboss.org/dms/tools/images/tools-banner.png"
/></td>
+ <td colspan="3" class="td_header"> </td>
</tr>
<tr>
<td>      </td>
@@ -44,8 +40,8 @@
<li>When the site loads, select the features to install,
or click the <code><strong>Select All</strong></code>
button.</li>
<li>To properly resolve all dependencies, check
- <ul><code><strong>[x] Contact all update sites during install
to find required software</strong></code></ul>
-
+ <ul><code><strong>[x] Contact all update sites during install
to find required software</strong></code></ul>
+
<li>Click <code><strong>Next</strong></code>,
agree to the license
terms, and install.</li>
Modified: trunk/build/tycho-plugins/repository-utils/src/main/resources/web/site.css
===================================================================
--- trunk/build/tycho-plugins/repository-utils/src/main/resources/web/site.css 2012-10-11
10:27:06 UTC (rev 44425)
+++ trunk/build/tycho-plugins/repository-utils/src/main/resources/web/site.css 2012-10-11
10:27:33 UTC (rev 44426)
@@ -9,10 +9,17 @@
color: #1778be;
}
+.table {
+ margin-top: 0px;
+ margin-left: 0px;
+ width: 920px;
+}
+
.bodyText {
font-family: sans-serif;
font-size: 9pt;
color: #000000;
+ width: 100%
}
.sub-header {
@@ -62,6 +69,11 @@
color: #187dc6;
}
+.td_header {
+ background:
url("https://www.jboss.org/dms/tools/images/tools-banner.png") 0
no-repeat;
+ height: 100px;
+}
+
.column-header {
font-size:small;
}