Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Williams2013-02-26 21:51:12 +0000
committerThanh Ha2013-03-12 13:20:56 +0000
commit32cd4557c306cbb0285a2bb3a3346e86c86bf252 (patch)
treec655d7a86458e405358deb8b985024cdc76847da
parent3cc3bb99ae2ac807218104fca150398ef3dd30f2 (diff)
downloadeclipse.platform.releng.aggregator-32cd4557c306cbb0285a2bb3a3346e86c86bf252.tar.gz
eclipse.platform.releng.aggregator-32cd4557c306cbb0285a2bb3a3346e86c86bf252.tar.xz
eclipse.platform.releng.aggregator-32cd4557c306cbb0285a2bb3a3346e86c86bf252.zip
Bug 399893 - Move maven-cbi-plugin to org.eclipse.cbi
-rw-r--r--maven-cbi-plugin/.gitignore5
-rw-r--r--maven-cbi-plugin/pom.xml74
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/AbstractPluginScannerMojo.java97
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/GenerateAPIBuildXMLMojo.java158
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/PluginVersionsMojo.java42
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/TestPropertiesMojo.java217
6 files changed, 0 insertions, 593 deletions
diff --git a/maven-cbi-plugin/.gitignore b/maven-cbi-plugin/.gitignore
deleted file mode 100644
index aba6df246..000000000
--- a/maven-cbi-plugin/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.project
-.classpath
-.settings/
-target/
-bin/
diff --git a/maven-cbi-plugin/pom.xml b/maven-cbi-plugin/pom.xml
deleted file mode 100644
index 2f991348f..000000000
--- a/maven-cbi-plugin/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2012 Eclipse Foundation.
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Distribution License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/org/documents/edl-v10.php
-
- Contributors:
- Igor Fedorenko - initial implementation
--->
-
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.eclipse.cbi</groupId>
- <artifactId>maven-cbi-plugin</artifactId>
- <version>0.0.2-SNAPSHOT</version>
- <packaging>maven-plugin</packaging>
-
- <properties>
- <maven.version>3.0</maven.version>
- <tycho.version>0.15.0</tycho.version>
- <tycho-repo.url>https://oss.sonatype.org/content/groups/public/</tycho-repo.url>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.tycho</groupId>
- <artifactId>tycho-core</artifactId>
- <version>${tycho.version}</version>
- </dependency>
- <dependency>
- <groupId>de.pdark</groupId>
- <artifactId>decentxml</artifactId>
- <version>1.3</version>
- </dependency>
-
- </dependencies>
-
- <repositories>
- <repository>
- <id>tycho</id>
- <url>${tycho-repo.url}</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven.version}</version>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/AbstractPluginScannerMojo.java b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/AbstractPluginScannerMojo.java
deleted file mode 100644
index bf6c50296..000000000
--- a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/AbstractPluginScannerMojo.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Eclipse Foundation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eclipse Foundation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cbi.mojo;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.IOUtil;
-import org.eclipse.tycho.core.osgitools.BundleReader;
-import org.eclipse.tycho.core.osgitools.OsgiManifest;
-import org.eclipse.tycho.core.osgitools.OsgiManifestParserException;
-
-abstract class AbstractPluginScannerMojo
- extends AbstractMojo
-{
- /**
- * igorf: as of 2012-01-05, generated repository location is hardcoded to target/repository in tycho
- *
- * @parameter default-value="${project.build.directory}/repository"
- **/
- protected File repository;
-
- /** @component */
- protected BundleReader bundleReader;
-
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
- try
- {
- Properties properties = new Properties();
-
- File[] plugins = new File( repository, "plugins" ).listFiles();
-
- if ( plugins != null )
- {
- Map<File, OsgiManifest> manifests = new HashMap<File, OsgiManifest>();
- for ( File plugin : plugins )
- {
- if ( plugin.getName().endsWith( ".pack.gz" ) )
- {
- continue;
- }
- try
- {
- OsgiManifest manifest = bundleReader.loadManifest( plugin );
- manifests.put( plugin, manifest );
- }
- catch ( OsgiManifestParserException e )
- {
- getLog().error( e );
- }
- }
-
- processPlugins( properties, manifests );
- }
-
- OutputStream os = new BufferedOutputStream( new FileOutputStream( getDestination() ) );
-
- try
- {
- properties.store( os, null );
- }
- finally
- {
- IOUtil.close( os );
- }
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( "Could not write plugin versions", e );
- }
- }
-
- protected abstract void processPlugins( Properties properties, Map<File, OsgiManifest> plugins )
- throws Exception;
-
- protected abstract File getDestination();
-
-}
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
deleted file mode 100644
index 9cce2c3f6..000000000
--- a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/GenerateAPIBuildXMLMojo.java
+++ /dev/null
@@ -1,158 +0,0 @@
-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
- project.getProperties().setProperty("eclipserun.skip", "true");
- return;
- }
- if (dotProjectContainsApiNature(dotProject)) {
- generateBuildXML();
- } else {
- project.getProperties().setProperty("eclipserun.skip", "true");
- }
- }
-
- 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;
- }
-}
diff --git a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/PluginVersionsMojo.java b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/PluginVersionsMojo.java
deleted file mode 100644
index ef368a8f7..000000000
--- a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/PluginVersionsMojo.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Eclipse Foundation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eclipse Foundation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cbi.mojo;
-
-import java.io.File;
-import java.util.Map;
-import java.util.Properties;
-
-import org.eclipse.tycho.core.osgitools.OsgiManifest;
-
-/**
- * @goal plugin-versions
- */
-public class PluginVersionsMojo
- extends AbstractPluginScannerMojo
-{
- /** @parameter default-value="${project.build.directory}/plugin-versions.properties" */
- protected File destination;
-
- @Override
- protected void processPlugins( Properties properties, Map<File, OsgiManifest> plugins )
- {
- for ( OsgiManifest manifest : plugins.values() )
- {
- properties.put( manifest.getBundleSymbolicName(), manifest.getBundleVersion() );
- }
- }
-
- @Override
- protected File getDestination()
- {
- return destination;
- }
-}
diff --git a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/TestPropertiesMojo.java b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/TestPropertiesMojo.java
deleted file mode 100644
index 0c8f0f18c..000000000
--- a/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/TestPropertiesMojo.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Eclipse Foundation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eclipse Foundation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cbi.mojo;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-
-import org.codehaus.plexus.util.IOUtil;
-import org.eclipse.osgi.util.ManifestElement;
-import org.eclipse.tycho.ArtifactKey;
-import org.eclipse.tycho.core.osgitools.DefaultArtifactKey;
-import org.eclipse.tycho.core.osgitools.OsgiManifest;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-import de.pdark.decentxml.Document;
-import de.pdark.decentxml.Element;
-import de.pdark.decentxml.XMLIOSource;
-import de.pdark.decentxml.XMLParser;
-
-/**
- * @goal test-properties
- */
-public class TestPropertiesMojo
- extends AbstractPluginScannerMojo
-{
- private static enum TestType
- {
- NONE, TEST, PERFTEST
- };
-
- private static class Plugin
- {
- private final OsgiManifest manifest;
-
- private final TestType testType;
-
- public Plugin( OsgiManifest manifest, TestType testType )
- {
- this.manifest = manifest;
- this.testType = testType;
- }
-
- public OsgiManifest getManifest()
- {
- return manifest;
- }
-
- public TestType getTestType()
- {
- return testType;
- }
- }
-
- private static XMLParser parser = new XMLParser();
-
- /** @parameter default-value="${project.build.directory}/test.properties" */
- protected File destination;
-
- @Override
- protected File getDestination()
- {
- return destination;
- }
-
- @Override
- protected void processPlugins( Properties properties, Map<File, OsgiManifest> plugins )
- throws Exception
- {
- Map<String, Plugin> model = new HashMap<String, Plugin>();
-
- for ( Map.Entry<File, OsgiManifest> entry : plugins.entrySet() )
- {
- TestType type = getTestType( entry.getKey() );
- OsgiManifest manifest = entry.getValue();
- model.put( manifest.getBundleSymbolicName(), new Plugin( manifest, type ) );
- }
-
- for ( Plugin plugin : model.values() )
- {
- if ( TestType.NONE == plugin.getTestType() )
- {
- continue;
- }
-
- OsgiManifest manifest = plugin.getManifest();
-
- properties.put( manifest.getBundleSymbolicName(),
- manifest.getBundleSymbolicName() + "_" + manifest.getBundleVersion() );
-
- if ( TestType.PERFTEST == plugin.getTestType() )
- {
- properties.put( manifest.getBundleSymbolicName() + ".has.performance.target", "true" );
- }
-
- List<Plugin> dependencies = new ArrayList<Plugin>();
- collectRequiredBundles( plugin, model, dependencies, new HashSet<ArtifactKey>() );
- StringBuilder sb = new StringBuilder();
- for ( Plugin dependency : dependencies )
- {
- if ( plugin == dependency )
- {
- continue;
- }
-
- if ( TestType.NONE == dependency.getTestType() )
- {
- continue;
- }
-
- if ( sb.length() > 0 )
- {
- sb.append( " " );
- }
-
- sb.append( "**/${" ).append( dependency.getManifest().getBundleSymbolicName() ).append( "}**" );
- }
-
- properties.put( manifest.getBundleSymbolicName() + ".prerequisite.testplugins", sb.toString() );
- }
- }
-
- private void collectRequiredBundles( Plugin plugin, Map<String, Plugin> model, Collection<Plugin> required,
- Set<ArtifactKey> visited )
- throws BundleException
- {
- ArtifactKey key = newArtifactKey( plugin );
- if ( visited.add( key ) )
- {
- required.add( plugin );
-
- OsgiManifest manifest = plugin.getManifest();
-
- String value = manifest.getValue( Constants.REQUIRE_BUNDLE );
- if ( value == null )
- {
- return;
- }
- ManifestElement[] elements = ManifestElement.parseHeader( Constants.REQUIRE_BUNDLE, value );
- if ( elements == null )
- {
- return;
- }
- for ( ManifestElement element : elements )
- {
- Plugin other = model.get( element.getValue() );
- if ( other != null )
- {
- collectRequiredBundles( other, model, required, visited );
- }
- }
- }
- }
-
- private ArtifactKey newArtifactKey( Plugin plugin )
- {
- OsgiManifest m = plugin.getManifest();
- return new DefaultArtifactKey( ArtifactKey.TYPE_ECLIPSE_PLUGIN, m.getBundleSymbolicName(), m.getBundleVersion() );
- }
-
- private TestType getTestType( File plugin )
- throws IOException
- {
- JarFile jar = new JarFile( plugin );
- try
- {
- ZipEntry entry = jar.getEntry( "test.xml" );
- if ( entry == null )
- {
- return TestType.NONE;
- }
- Document document;
- InputStream is = jar.getInputStream( entry );
- try
- {
- document = parser.parse( new XMLIOSource( is ) );
- }
- finally
- {
- IOUtil.close( is );
- }
-
- for ( Element element : document.getRootElement().getChildren( "target" ) )
- {
- if ( "performance".equals( element.getAttributeValue( "name" ) ) )
- {
- return TestType.PERFTEST;
- }
- }
-
- return TestType.TEST;
- }
- finally
- {
- jar.close();
- }
- }
-}

Back to the top