Author: mickael_istria
Date: 2012-02-27 11:23:57 -0500 (Mon, 27 Feb 2012)
New Revision: 39148
Added:
trunk/build/tycho-plugins/
trunk/build/tycho-plugins/generate-repository-facade/
trunk/build/tycho-plugins/generate-repository-facade/.classpath
trunk/build/tycho-plugins/generate-repository-facade/.project
trunk/build/tycho-plugins/generate-repository-facade/.settings/
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.jdt.core.prefs
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.m2e.core.prefs
trunk/build/tycho-plugins/generate-repository-facade/pom.xml
trunk/build/tycho-plugins/generate-repository-facade/src/
trunk/build/tycho-plugins/generate-repository-facade/src/main/
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/tycho/
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/tycho/sitegenerator/
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/index.html
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.properties.xsl
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.xsl
trunk/build/tycho-plugins/generate-repository-facade/src/test/
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/FileTest.java
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/XsltTest.java
Log:
JBIDE-11065
Plugin to generate repository files (as done in build.xml)
Added: trunk/build/tycho-plugins/generate-repository-facade/.classpath
===================================================================
--- trunk/build/tycho-plugins/generate-repository-facade/.classpath
(rev 0)
+++ trunk/build/tycho-plugins/generate-repository-facade/.classpath 2012-02-27 16:23:57
UTC (rev 39148)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes"
path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes"
path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Property changes on: trunk/build/tycho-plugins/generate-repository-facade/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/build/tycho-plugins/generate-repository-facade/.project
===================================================================
--- trunk/build/tycho-plugins/generate-repository-facade/.project
(rev 0)
+++ trunk/build/tycho-plugins/generate-repository-facade/.project 2012-02-27 16:23:57 UTC
(rev 39148)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>generate-repository-facade</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/build/tycho-plugins/generate-repository-facade/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.jdt.core.prefs 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.m2e.core.prefs
===================================================================
---
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.m2e.core.prefs
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.m2e.core.prefs 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/.settings/org.eclipse.m2e.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/build/tycho-plugins/generate-repository-facade/pom.xml
===================================================================
--- trunk/build/tycho-plugins/generate-repository-facade/pom.xml
(rev 0)
+++ trunk/build/tycho-plugins/generate-repository-facade/pom.xml 2012-02-27 16:23:57 UTC
(rev 39148)
@@ -0,0 +1,64 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.tools.tycho</groupId>
+ <artifactId>generate-repository-facade</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>Mojo to Generate site.xml for eclipse-repository</name>
+
+ <properties>
+ <tychoVersion>0.14.0</tychoVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-facade</artifactId>
+ <version>${tychoVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <version>${tychoVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-core</artifactId>
+ <version>${tychoVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-dom</artifactId>
+ <version>8.7</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>central</id>
+ <
url>http://repo1.maven.org/maven2</url>
+ <layout>default</layout>
+ <releases><enabled>true</enabled></releases>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>central-plugin</id>
+ <
url>http://repo1.maven.org/maven2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>
Property changes on: trunk/build/tycho-plugins/generate-repository-facade/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java
===================================================================
---
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,367 @@
+package org.jboss.tools.tycho.sitegenerator;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.archiver.zip.ZipArchiver;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.io.RawInputStreamFacade;
+import org.eclipse.tycho.ArtifactKey;
+import org.eclipse.tycho.ReactorProject;
+import org.eclipse.tycho.core.ArtifactDependencyVisitor;
+import org.eclipse.tycho.core.FeatureDescription;
+import org.eclipse.tycho.core.osgitools.EclipseRepositoryProject;
+import org.eclipse.tycho.model.FeatureRef;
+import org.eclipse.tycho.model.UpdateSite;
+import org.eclipse.tycho.model.UpdateSite.SiteFeatureRef;
+import org.eclipse.tycho.packaging.AbstractTychoPackagingMojo;
+import org.eclipse.tycho.packaging.UpdateSiteAssembler;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Goal which touches a timestamp file.
+ *
+ * @goal generate-repository-facade
+ *
+ * @phase package
+ */
+public class GenerateRepositoryFacadeMojo extends AbstractTychoPackagingMojo {
+ /**
+ * @parameter expression="${session}"
+ * @readonly
+ */
+ private MavenSession session;
+
+ /**
+ * @parameter expression="${project}"
+ * @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
+ */
+ private List<String> associateSites;
+
+ /**
+ * name of the file in ${siteTemplateFolder} to use as template for index.html
+ * @parameter default-value="index.html"
+ */
+ private String indexName;
+
+ public void execute() throws MojoExecutionException
+ {
+ getLog().warn("sites:" + associateSites.size());
+ if (!ArtifactKey.TYPE_ECLIPSE_REPOSITORY.equals(project.getPackaging())) {
+ return;
+ }
+
+ if (symbols == null) {
+ symbols = new HashMap<String, String>();
+ }
+ // TODO populate default symbols: ${update.site.name} &
${update.site.description}
+
+ File outputRepository = new File(project.getBuild().getDirectory(),
"repository");
+ File outputSiteXml = generateSiteXml(outputRepository);
+ generateSiteProperties(outputRepository, outputSiteXml);
+ generateJBossToolsDirectoryXml(outputRepository);
+ generateWebStuff(outputRepository, outputSiteXml);
+ try {
+ alterContentJar(outputRepository);
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Error while altering
content.jar",ex);
+ }
+
+
+ File repoZipFile = new File(project.getBuild().getDirectory(),
"repository.zip");
+ repoZipFile.delete();
+ try {
+ ZipArchiver archiver = new ZipArchiver();
+ archiver.setDestFile(repoZipFile);
+ archiver.setForced(true);
+ archiver.addDirectory(outputRepository);
+ archiver.createArchive();
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Could not create " +
repoZipFile.getName(), ex);
+ }
+
+ }
+
+ private void generateWebStuff(File outputRepository, File outputSiteXml)
+ throws TransformerFactoryConfigurationError, MojoExecutionException {
+ // Generate index.html
+ try {
+ InputStream siteXsl =
getClass().getResourceAsStream("/xslt/site.xsl");
+ Source xsltSource = new StreamSource(siteXsl);
+ Transformer transformer =
TransformerFactory.newInstance().newTransformer(xsltSource);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Result res = new StreamResult(out);
+ transformer.transform(new StreamSource(outputSiteXml), res);
+ siteXsl.close();
+ out.close();
+ symbols.put("${site.contents}", out.toString());
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Error occured while generating
'site.properties'", ex);
+ }
+
+
+ try {
+ copyTemplateResources(outputRepository);
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Error while copying siteTemplateFolder
content to " + outputRepository, ex);
+ }
+ try {
+ alterIndexFile(outputRepository);
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Error writing file " + indexName,
ex);
+ }
+ }
+
+ private void generateJBossToolsDirectoryXml(File outputRepository)
+ throws MojoExecutionException {
+ // Generate jbosstools-directory.xml
+ File[] org_jboss_tools_central_discovery = new File(outputRepository,
"plugins").listFiles(new FileFilter() {
+ public boolean accept(File arg0) {
+ return arg0.getName().startsWith("org.jboss.tools.central.discovery_")
&& arg0.getName().endsWith(".jar");
+ }
+ });
+ if (org_jboss_tools_central_discovery.length > 0) {
+ try {
+ FileOutputStream directoryXml = new FileOutputStream(new File(outputRepository,
"jbosstools-directory.xml"));
+ directoryXml.write("<directory
xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\">...);
+ directoryXml.write("<entry url=\"plugins/".getBytes());
+ directoryXml.write(org_jboss_tools_central_discovery[0].getName().getBytes());
+ directoryXml.write("\"
permitCategories=\"true\"/>\n".getBytes());
+ directoryXml.write("</directory>".getBytes());
+ directoryXml.close();
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Could not write file
'jbosstools-directory.xml'", ex);
+ }
+ }
+ if (org_jboss_tools_central_discovery.length == 0) {
+ getLog().warn("No org.jboss.tools.central.discovery plugin in repo. Skip
generatio of 'jbosstools-directory.xml'");
+ }
+ if (org_jboss_tools_central_discovery.length > 1) {
+ getLog().warn("Several org.jbosstools.central.discovery plugin in
repo");
+ }
+ }
+
+ private void generateSiteProperties(File outputRepository,
+ File outputSiteXml) throws TransformerFactoryConfigurationError,
+ MojoExecutionException {
+ // Generate site.properties
+ try {
+ InputStream siteXsl =
getClass().getResourceAsStream("/xslt/site.properties.xsl");
+ Source xsltSource = new StreamSource(siteXsl);
+ Transformer transformer =
TransformerFactory.newInstance().newTransformer(xsltSource);
+ FileOutputStream out = new FileOutputStream(new File(outputRepository,
"site.properties"));
+ Result res = new StreamResult(out);
+ transformer.transform(new StreamSource(outputSiteXml), res);
+ siteXsl.close();
+ out.close();
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Error occured while generating
'site.properties'", ex);
+ }
+
+ try {
+ copyTemplateResources(outputRepository);
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Error while copying siteTemplateFolder
content to " + outputRepository, ex);
+ }
+ }
+
+ private File generateSiteXml(File outputRepository)
+ throws MojoExecutionException {
+ // Generate site.xml
+ File categoryFile = new File(project.getBasedir(), "category.xml");
+ if (!categoryFile.isFile()) {
+ throw new MojoExecutionException("Missing 'category.xml
file'");
+ }
+
+ UpdateSite site = null;
+ try {
+ site = UpdateSite.read(categoryFile);
+ } catch (IOException ex) {
+ throw new MojoExecutionException("Could not read 'category.xml'
file", ex);
+ }
+ new EclipseRepositoryProject().getDependencyWalker(project).traverseUpdateSite(site,
new ArtifactDependencyVisitor() {
+ @Override
+ public boolean visitFeature(FeatureDescription feature) {
+ FeatureRef featureRef = feature.getFeatureRef();
+ String id = featureRef.getId();
+ ReactorProject otherProject = feature.getMavenProject();
+ String version;
+ if (otherProject != null) {
+ version = otherProject.getExpandedVersion();
+ } else {
+ version = feature.getKey().getVersion();
+ }
+ String url = UpdateSiteAssembler.FEATURES_DIR + id + "_" +
version + ".jar";
+ ((SiteFeatureRef) featureRef).setUrl(url);
+ featureRef.setVersion(version);
+ return false; // don't traverse included features
+ }
+ });
+
+ File outputSiteXml = new File(outputRepository, "site.xml");
+ try {
+ if (!outputSiteXml.exists()) {
+ outputSiteXml.createNewFile();
+ }
+ UpdateSite.write(site, outputSiteXml);
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ throw new MojoExecutionException("Could not write site.xml to '" +
outputSiteXml.getAbsolutePath() + "'", ex);
+ }
+ return outputSiteXml;
+ }
+
+ private void alterContentJar(File outputRepository)
+ throws FileNotFoundException, IOException, SAXException,
+ ParserConfigurationException, TransformerFactoryConfigurationError,
+ TransformerConfigurationException, TransformerException {
+ File contentJar = new File(outputRepository, "content.jar");
+ ZipInputStream contentStream = new ZipInputStream(new
FileInputStream(contentJar));
+ ZipEntry entry = null;
+ Document contentDoc = null;
+ boolean done = false;
+ while (!done && (entry = contentStream.getNextEntry()) != null) {
+ if (entry.getName().equals("content.xml")) {
+ contentDoc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(contentStream);
+ Element repoElement =
(Element)contentDoc.getElementsByTagName("repository").item(0);
+ NodeList references =
repoElement.getElementsByTagName("references");
+ for (int i = 0; i < references.getLength(); i++) {
+ Node currentRef = references.item(i);
+ currentRef.getParentNode().removeChild(currentRef);
+ }
+ if (associateSites != null && associateSites.size() > 0) {
+ Element refElement = contentDoc.createElement("references");
+ refElement.setAttribute("size", Integer.valueOf(2 *
associateSites.size()).toString());
+ for (String associate : associateSites) {
+ Element rep0 = contentDoc.createElement("repository");
+ rep0.setAttribute("uri", associate);
+ rep0.setAttribute("url", associate);
+ rep0.setAttribute("type", "0");
+ rep0.setAttribute("options", "1");
+ refElement.appendChild(rep0);
+ Element rep1 = (Element)rep0.cloneNode(true);
+ refElement.appendChild(rep1);
+ }
+ repoElement.appendChild(refElement);
+ }
+ done = true;
+ }
+ }
+ // .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");
+ outContentStream.putNextEntry(contentXmlEntry);
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ Transformer transformer = tFactory.newTransformer();
+ DOMSource source = new DOMSource(contentDoc);
+ StreamResult result = new StreamResult(outContentStream);
+ transformer.transform(source, result);
+ outContentStream.closeEntry();
+ outContentStream.close();
+ }
+
+ private void alterIndexFile(File outputSite) throws FileNotFoundException, IOException
{
+ File templateFile = new File(outputSite, indexName);
+ FileInputStream fis = new FileInputStream(templateFile);
+ String htmlFile = IOUtil.toString(fis, "UTF-8");
+ for (Entry<String, String> entry : symbols.entrySet()) {
+ String key = entry.getKey();
+ if (!key.startsWith("${")) {
+ key = "${" + key + "}";
+ }
+ htmlFile = htmlFile.replace(key, entry.getValue());
+ }
+ FileOutputStream out = new FileOutputStream(templateFile);
+ out.write(htmlFile.getBytes("UTF-8"));
+ out.close();
+ }
+
+ private void copyTemplateResources(File outputSite) throws IOException {
+ if (siteTemplateFolder != null) {
+ FileUtils.copyDirectory(siteTemplateFolder, outputSite);
+ } else {
+ // load from resources
+ InputStream indexStream = getClass().getResourceAsStream("/index.html");
+ indexName = "index.html";
+ FileUtils.copyStreamToFile(new RawInputStreamFacade(indexStream), new File(outputSite,
"index.html"));
+ indexStream.close();
+ File webFolder = new File(outputSite, "web");
+ if (!webFolder.exists()) {
+ webFolder.mkdir();
+ }
+ InputStream cssStream = getClass().getResourceAsStream("/web/site.css");
+ FileUtils.copyStreamToFile(new RawInputStreamFacade(cssStream), new File(webFolder,
"site.css"));
+ cssStream.close();
+ }
+ }
+}
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/index.html
===================================================================
--- trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/index.html
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/index.html 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,136 @@
+<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>
+</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">
+ <tr>
+ <td colspan="3"><img
+
src="https://www.jboss.org/dms/tools/images/tools-banner.png"
/></td>
+ </tr>
+ <tr>
+ <td>      </td>
+ <td>      </td>
+ <td>      </td>
+ </tr>
+ <tr>
+ <td>      </td>
+ <td>
+ <h2 class="title">${update.site.name} - ${update.site.description}
Update Site</h2>
+ <table width="100%">
+ <tr class="header">
+ <td class="sub-header" width="100%"><span>Latest
Build${update.site.version}</span></td>
+ </tr>
+
+ <tr class="light-row" style="height: 30px">
+ <td class="bodyText">
+ <p class="bodyText">This is the
<b>${update.site.description}</b>
+ Update Site for ${update.site.name}.
+ <blockquote style="border: 1px dashed #1778be; padding: 2px">
+ <ol>
+ <li>To <a class="link"
+
href="http://www.jboss.org/tools/download/installation/update_3_3&qu...
+ from this site, start up Eclipse 3.7, then do:
+ <ul>
+ <code><strong>Help > Install New Software...
></strong></code>
+ </ul>
+ </li>
+ <li>Copy this site's URL into Eclipse, and hit Enter.</li>
+ <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>
+
+ <li>Click <code><strong>Next</strong></code>,
agree to the license
+ terms, and install.</li>
+
+ <p class="bodyText">
+ You can also download JBoss Tools as individual zips for
+ offline installation. See <a class="link"
+
href="http://www.jboss.org/tools/download">JBoss Tools
+ Downloads</a>.<br /> If you downloaded this site as a zip, see
+ <a href="README.installation.txt">Installation
README</a>.
+ See also <a
+
href="http://www.jboss.org/tools/download/installation">Inst...
+ methods</a>.
+ </p>
+ </ol>
+ </blockquote>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>      </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ ${site.contents}
+ </td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <table width="100%">
+ <tr class="header">
+ <td class="sub-header" width="100%"><span>
Installation
+ Types</span></td>
+ </tr>
+ <tr class="light-row" style="height: 30px">
+ <td class="bodyText">
+ <p class="bodyText">Depending on how close to the bleeding edge
+ you like to be, there are several types of releases available.</p>
+ <br />
+
+ </td>
+ </tr>
+
+ <tr class="dark-row" style="height: 30px">
+ <td class="bodyText">
+ <h4>Stable Releases</h4>
+
+ <p><a
href="https://www.jboss.org/tools/download/stable.html">Stable
+ releases</a> are - as indicated by their name - stable.</p><br/>
+
+ </td>
+ </tr>
+
+ <tr class="light-row" style="height: 30px">
+ <td class="bodyText">
+ <h4>Development Milestones</h4>
+
+ <p><a
href="https://www.jboss.org/tools/download/dev.html">Develop...
+ builds</a>, released once per milestone and only a few times a year, are
+ fairly stable, but there may be some things which do not yet work.
+ If you would like to try one of these milestones, we'd greatly
+ appreciate the assistance in testing and <a
+
href="https://jira.jboss.org/jira/browse/JBIDE">reporting of
+ issues in our issue tracker</a>.</p><br/>
+
+ </td>
+ </tr>
+
+ <tr class="dark-row" style="height: 30px">
+ <td class="bodyText">
+ <h4>Nightly Builds</h4>
+
+ <p>The <a
+
href="https://www.jboss.org/tools/download/nightly.html">ble...
+ edge</a> contains the latest and greatest new features, but nothing is
+ stable or guaranteed - yet. If you're using a Milestone and need a
+ fix, you can update to the latest Nightly, or wait for the next
+ Milestone.</p><br/>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</center>
+</html>
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/index.html
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.properties.xsl
===================================================================
---
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.properties.xsl
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.properties.xsl 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,20 @@
+<xsl:stylesheet version="2.0"
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
+
xmlns:saxon="http://saxon.sf.net/"
xmlns="http://www.w3.org/1999/xhtml"
+ extension-element-prefixes="saxon">
+ <xsl:output method="text" indent="yes" />
+ <xsl:template match="/site">
+ <xsl:for-each select="category-def">
+ <xsl:sort select="@name" />
+ <xsl:variable name="catg"><xsl:value-of
select="@name"/></xsl:variable>
+#
+<xsl:value-of select="$catg" />.category.features = \
+<xsl:for-each select="//feature">
+ <xsl:sort select="@id" />
+ <xsl:if
test="count(./category[contains(@name,$catg)])>0"><xsl:value-of
select="@id" />,
+</xsl:if>
+ </xsl:for-each>
+ </xsl:for-each>
+#
+ </xsl:template>
+</xsl:stylesheet>
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.properties.xsl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.xsl
===================================================================
--- trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.xsl
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.xsl 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,123 @@
+<xsl:stylesheet version="2.0"
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
+
xmlns:saxon="http://saxon.sf.net/"
xmlns="http://www.w3.org/1999/xhtml"
+ extension-element-prefixes="saxon">
+ <xsl:output method="html" indent="yes" />
+ <xsl:template match="/site">
+ <table cellspacing="2" cellpadding="0" border="0">
+ <xsl:if test="count(feature[contains(@id,'jboss')])>0">
+ <tr style="background-color:#DDDDDD">
+ <th class="column-header">Feature</th>
+ <th class="column-header">Version</th>
+ <th class="column-header">Feature Categor(ies)</th>
+ </tr>
+ <!-- JBoss features -->
+ <xsl:for-each select="feature[contains(@id,'jboss')]">
+ <xsl:sort select="@id" />
+ <xsl:variable name="rowCol">
+ <xsl:if test="position() mod 2 = 1">
+ #EEEEEE
+ </xsl:if>
+ <xsl:if test="position() mod 2 = 0">
+ #FFFFFF
+ </xsl:if>
+ </xsl:variable>
+
+ <tr style="background-color:{$rowCol}">
+ <td class="rowLine">
+ <a href="{@url}" style="font-size:x-small">
+ <xsl:value-of select="@id" />
+ </a>
+ </td>
+ <td>
+ <span style="font-size:x-small">
+ <xsl:value-of select="@version" />
+ </span>
+ </td>
+ <td>
+ <xsl:choose>
+ <xsl:when test="category">
+ <xsl:for-each select="category">
+ <span style="font-size:x-small">
+ |
+ <xsl:value-of select="@name" />
+ </span>
+ </xsl:for-each>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </xsl:if>
+ <xsl:if
test="count(feature[not(contains(@id,'jboss'))])>0">
+ <tr style="background-color:#DDDDDD">
+ <th class="column-header">Feature</th>
+ <th class="column-header">Version</th>
+ <th class="column-header">Feature Categor(ies)</th>
+ </tr>
+ <!-- other features -->
+ <xsl:for-each select="feature[not(contains(@id,'jboss'))]">
+ <xsl:sort select="@id" />
+ <xsl:variable name="rowCol">
+ <xsl:if test="position() mod 2 = 1">
+ #EEEEEE
+ </xsl:if>
+ <xsl:if test="position() mod 2 = 0">
+ #FFFFFF
+ </xsl:if>
+ </xsl:variable>
+
+ <tr style="background-color:{$rowCol}">
+ <td class="rowLine">
+ <a href="{@url}" style="font-size:x-small">
+ <xsl:value-of select="@id" />
+ </a>
+ </td>
+ <td>
+ <span style="font-size:x-small">
+ <xsl:value-of select="@version" />
+ </span>
+ </td>
+ <td>
+ <xsl:choose>
+ <xsl:when test="category">
+ <xsl:for-each select="category">
+ <span style="font-size:x-small">
+ |
+ <xsl:value-of select="@name" />
+ </span>
+ </xsl:for-each>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </xsl:if>
+
+ <tr style="background-color:#DDDDDD">
+ <th class="column-header">Feature</th>
+ <th class="column-header">Version</th>
+ <th class="column-header">Feature Categor(ies)</th>
+ </tr>
+ <tr style="background-color:#EEEEEE">
+ <td class="rowLine" colspan="1">
+ <a href="site.xml"
style="font-size:x-small">site.xml</a>
+ ::
+ <a href="artifacts.jar"
style="font-size:x-small">artifacts.jar</a>
+ ::
+ <a href="content.jar"
style="font-size:x-small">content.jar</a>
+ </td>
+ <td class="rowLine" colspan="1">
+ ::
+ <a href="plugins/"
style="font-size:x-small">plugins</a>
+ ::
+ <a href="features/"
style="font-size:x-small">features</a>
+ </td>
+ <td class="rowLine" colspan="1">
+ <a href="jbosstools-directory.xml"
style="font-size:x-small">directory.xml</a> | <a
href="site.properties"
style="font-size:x-small">site.properties</a>
+ </td>
+ </tr>
+ </table>
+ <br />
+ </xsl:template>
+</xsl:stylesheet>
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/src/main/resources/xslt/site.xsl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/FileTest.java
===================================================================
---
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/FileTest.java
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/FileTest.java 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,14 @@
+package org.jboss.tools.tycho.sitegenerator;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class FileTest {
+
+ @Test
+ public void testReplace() {
+ assertEquals("replaced", new
String("${site.contents}").replace("${site.contents}",
"replaced"));
+ }
+
+}
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/FileTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/XsltTest.java
===================================================================
---
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/XsltTest.java
(rev 0)
+++
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/XsltTest.java 2012-02-27
16:23:57 UTC (rev 39148)
@@ -0,0 +1,30 @@
+package org.jboss.tools.tycho.sitegenerator;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Test;
+
+public class XsltTest {
+
+ @Test
+ public void testSiteProperties() throws Exception {
+ InputStream siteXsl =
GenerateRepositoryFacadeMojo.class.getResourceAsStream("/xslt/site.properties.xsl");
+ Source xsltSource = new StreamSource(siteXsl);
+ Transformer transformer =
TransformerFactory.newInstance().newTransformer(xsltSource);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Result res = new StreamResult(out);
+ transformer.transform(new StreamSource(new
ByteArrayInputStream("<site/>".getBytes())), res);
+ siteXsl.close();
+ out.close();
+ }
+
+}
Property changes on:
trunk/build/tycho-plugins/generate-repository-facade/src/test/java/org/jboss/tools/tycho/sitegenerator/XsltTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain