aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Daniel2013-01-28 10:06:41 (EST)
committerThanh Ha2013-01-28 10:06:41 (EST)
commite20c0830d1da052b286fe2206ee818c6073dfae1 (patch)
treeed337a7edf9f87793b679637d19dacd8aff73386
parentd392dc2940e56a011c229ef5330d280a2208dafd (diff)
downloadeclipse.platform.releng.aggregator-e20c0830d1da052b286fe2206ee818c6073dfae1.zip
eclipse.platform.releng.aggregator-e20c0830d1da052b286fe2206ee818c6073dfae1.tar.gz
eclipse.platform.releng.aggregator-e20c0830d1da052b286fe2206ee818c6073dfae1.tar.bz2
Bug 381057 - CBI should be able to generate the API tools description
-rw-r--r--eclipse-parent/pom.xml78
-rw-r--r--eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml2
-rw-r--r--maven-cbi-plugin/pom.xml2
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/GenerateAPIBuildXMLMojo.java155
4 files changed, 235 insertions, 2 deletions
diff --git a/eclipse-parent/pom.xml b/eclipse-parent/pom.xml
index 528bb5f..b136a76 100644
--- a/eclipse-parent/pom.xml
+++ b/eclipse-parent/pom.xml
@@ -96,6 +96,18 @@
<extensions>true</extensions>
</plugin>
<plugin>
+ <groupId>org.eclipse.cbi</groupId>
+ <artifactId>maven-cbi-plugin</artifactId>
+ <version>0.0.2-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-api-build-xml</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
@@ -491,6 +503,72 @@
<toolsjar>${java.home}/../Classes/classes.jar</toolsjar>
</properties>
</profile>
+ <profile>
+ <id>api-generation</id>
+ <activation>
+ <file>
+ <exists>.apibuild.xml</exists>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho.extras</groupId>
+ <artifactId>tycho-eclipserun-plugin</artifactId>
+ <!-- this is actually present in any 0.14+ version -->
+ <version>${tycho.version}</version>
+ <configuration>
+ <repositories>
+ <repository>
+ <id>juno</id>
+ <layout>p2</layout>
+ <url>http://download.eclipse.org/releases/juno</url>
+ </repository>
+ </repositories>
+ <!-- this is to fix some lucene 3.x compatibility issue -->
+ <argLine>-XX:-UseLoopPredicate -Dhelp.lucene.tokenizer=standard</argLine>
+ <!-- actuall indexer call -->
+ <appArgLine>-application org.eclipse.ant.core.antRunner -buildfile .apibuild.xml</appArgLine>
+ <dependencies>
+ <!-- list of bundles that we need -->
+ <dependency>
+ <artifactId>org.eclipse.ant.core</artifactId>
+ <type>eclipse-plugin</type>
+ </dependency>
+ <dependency>
+ <artifactId>org.apache.ant</artifactId>
+ <type>eclipse-plugin</type>
+ </dependency>
+ <dependency>
+ <artifactId>org.eclipse.pde.api.tools</artifactId>
+ <type>eclipse-plugin</type>
+ </dependency>
+ <dependency>
+ <artifactId>org.eclipse.pde.build</artifactId>
+ <type>eclipse-plugin</type>
+ </dependency>
+ <dependency>
+ <artifactId>org.eclipse.pde.core</artifactId>
+ <type>eclipse-plugin</type>
+ </dependency>
+ <dependency>
+ <artifactId>org.eclipse.equinox.launcher</artifactId>
+ <type>eclipse-plugin</type>
+ </dependency>
+ </dependencies>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>eclipse-run</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml b/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml
index c983258..5f85ab0 100644
--- a/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml
+++ b/eclipse.platform.releng.tychoeclipsebuilder/eclipse-junit-tests/pom.xml
@@ -165,7 +165,7 @@
<plugin>
<groupId>org.eclipse.cbi</groupId>
<artifactId>maven-cbi-plugin</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>0.0.2-SNAPSHOT</version>
<executions>
<execution>
<id>plugin-versions</id>
diff --git a/maven-cbi-plugin/pom.xml b/maven-cbi-plugin/pom.xml
index 94574f2..2f99134 100644
--- a/maven-cbi-plugin/pom.xml
+++ b/maven-cbi-plugin/pom.xml
@@ -15,7 +15,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.cbi</groupId>
<artifactId>maven-cbi-plugin</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>0.0.2-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<properties>
diff --git a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/GenerateAPIBuildXMLMojo.java b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/GenerateAPIBuildXMLMojo.java
new file mode 100644
index 0000000..1ea1913
--- /dev/null
+++ b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/GenerateAPIBuildXMLMojo.java
@@ -0,0 +1,155 @@
+package org.eclipse.tycho.pomgenerator;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.xml.XmlStreamReader;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.eclipse.osgi.framework.adaptor.FilePath;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.State;
+import org.eclipse.tycho.ArtifactDescriptor;
+import org.eclipse.tycho.ArtifactKey;
+import org.eclipse.tycho.core.TychoProject;
+import org.eclipse.tycho.core.osgitools.BundleReader;
+import org.eclipse.tycho.core.osgitools.DefaultArtifactKey;
+import org.eclipse.tycho.core.osgitools.DefaultReactorProject;
+import org.eclipse.tycho.core.osgitools.DependencyComputer;
+import org.eclipse.tycho.core.osgitools.EquinoxResolver;
+import org.eclipse.tycho.core.osgitools.OsgiManifest;
+import org.eclipse.tycho.core.osgitools.OsgiManifestParserException;
+import org.eclipse.tycho.core.osgitools.targetplatform.DefaultTargetPlatform;
+import org.eclipse.tycho.model.Feature;
+import org.eclipse.tycho.model.FeatureRef;
+import org.eclipse.tycho.model.PluginRef;
+import org.eclipse.tycho.model.UpdateSite;
+import org.osgi.framework.BundleException;
+
+/**
+ * @goal generate-api-build-xml
+ * @phase generate-sources
+ */
+public class GenerateAPIBuildXMLMojo extends AbstractMojo {
+
+ private static final String API_BUILD_XML_FILE = ".apibuild.xml";
+ private static final String API_NATURE = "org.eclipse.pde.api.tools.apiAnalysisNature";
+
+ /**
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * @component role="org.eclipse.tycho.core.TychoProject"
+ */
+ private Map<String, TychoProject> projectTypes;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ File dotProject = new File(project.getBasedir(), ".project");
+ if (!dotProject.exists()) {
+ // no .project
+ return;
+ }
+ if (dotProjectContainsApiNature(dotProject)) {
+ generateBuildXML();
+ }
+ }
+
+ private boolean dotProjectContainsApiNature(File f){
+ try{
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(f);
+ doc.getDocumentElement().normalize();
+ NodeList natures = doc.getElementsByTagName("nature");
+ for (int i = 0; i < natures.getLength(); i++) {
+
+ Node nature = natures.item(i);
+ String sNature = nature.getTextContent();
+ if( sNature != null){
+ if(API_NATURE.equals(sNature.trim())){
+ return true;
+ }
+ }
+ }
+ } catch (Exception e){
+ e.printStackTrace();
+ return false;
+ }
+ return false;
+ }
+
+ private void generateBuildXML(){
+ try {
+ System.out.println("Generating .apibuild.xml");
+ File dotApiBuildXML = new File(project.getBasedir(), API_BUILD_XML_FILE);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(dotApiBuildXML));
+ bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ bw.write("<project name=\"apigen\" default=\"apigen\">\n");
+ bw.write(" <target name=\"apigen\">\n");
+ bw.write(" <apitooling.apigeneration \n");
+ bw.write(" projectname=\"" + calculateName() + "\"\n");
+ bw.write(" project=\"" + project.getBasedir() + "\"\n");
+ bw.write(" binary=\"" + project.getBuild().getDirectory() + "\"\n");
+ bw.write(" target=\"" + project.getBuild().getDirectory() + "/classes\"\n");
+ bw.write(" debug=\"true\"\n");
+ bw.write(" \n");
+ bw.write(" />\n");
+ bw.write(" </target>\n");
+ bw.write("</project>\n");
+ bw.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String calculateName() {
+ TychoProject projectType = projectTypes.get(project.getPackaging());
+ ArtifactKey artifactKey = projectType
+ .getArtifactKey(DefaultReactorProject.adapt(project));
+ String symbolicName = artifactKey.getId();
+ String version = artifactKey.getVersion();
+ return symbolicName + "_" + version;
+ }
+}