Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2012-01-06 12:05:27 +0000
committerIgor Fedorenko2012-01-06 12:05:27 +0000
commit473a02176a8c47f9bf55d8529d8ed8d6df0e1e8f (patch)
tree84aff0729f559ebcddd86452347370df563101e6
parentbb3281df681ad12791c9e9cbaaa30dcfb7b5bb5c (diff)
downloadeclipse.platform.releng.aggregator-473a02176a8c47f9bf55d8529d8ed8d6df0e1e8f.tar.gz
eclipse.platform.releng.aggregator-473a02176a8c47f9bf55d8529d8ed8d6df0e1e8f.tar.xz
eclipse.platform.releng.aggregator-473a02176a8c47f9bf55d8529d8ed8d6df0e1e8f.zip
implemented approximation of eclipse-Automated-Tests
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--TMP/eclipse-junit-tests/pom.xml49
-rw-r--r--TMP/eclipse-junit-tests/src/main/assembly/assembly.xml7
-rw-r--r--TMP/eclipse-junit-tests/src/main/resources/label.properties7
-rw-r--r--maven-cbi-plugin/.gitignore5
-rw-r--r--maven-cbi-plugin/pom.xml53
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/AbstractPluginScannerMojo.java74
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/PluginVersionsMojo.java32
-rw-r--r--maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/TestPropertiesMojo.java207
-rw-r--r--pom.xml1
9 files changed, 430 insertions, 5 deletions
diff --git a/TMP/eclipse-junit-tests/pom.xml b/TMP/eclipse-junit-tests/pom.xml
index 380283a34..186fd634d 100644
--- a/TMP/eclipse-junit-tests/pom.xml
+++ b/TMP/eclipse-junit-tests/pom.xml
@@ -12,6 +12,10 @@
<artifactId>eclipse-junit-tests</artifactId>
<packaging>eclipse-repository</packaging>
+ <!--
+ igorf: I *guess* junit-tests is built by PDE/Build from org.eclipse.releng.eclipsebuilder/eclipse/buildConfigs/sdk.tests
+ -->
+
<build>
<resources>
<resource>
@@ -22,6 +26,24 @@
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.5</version>
+ <executions>
+ <execution>
+ <id>filter-resources</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/resources</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
@@ -69,6 +91,33 @@
</executions>
</plugin>
<plugin>
+ <groupId>org.eclipse.cbi</groupId>
+ <artifactId>maven-cbi-plugin</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>plugin-versions</id>
+ <goals>
+ <goal>plugin-versions</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <destination>${project.build.directory}/resources/finalPluginsVersions.properties</destination>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-properties</id>
+ <goals>
+ <goal>test-properties</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <destination>${project.build.directory}/resources/test.properties</destination>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
diff --git a/TMP/eclipse-junit-tests/src/main/assembly/assembly.xml b/TMP/eclipse-junit-tests/src/main/assembly/assembly.xml
index 3760543b7..86d59c11b 100644
--- a/TMP/eclipse-junit-tests/src/main/assembly/assembly.xml
+++ b/TMP/eclipse-junit-tests/src/main/assembly/assembly.xml
@@ -9,13 +9,16 @@
<directory>${project.basedir}/src/main/scripts</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
+ <fileSet>
+ <directory>${project.build.directory}/resources</directory>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/eclipse-junit-tests.zip</source>
<outputDirectory>/</outputDirectory>
- <destName>eclipse-junit-tests-${unqualifiedVersion}.${buildQualifier}.zip</destName>
+ <destName>eclipse-junit-tests-${buildQualifier}.zip</destName>
</file>
</files>
</assembly>
-
diff --git a/TMP/eclipse-junit-tests/src/main/resources/label.properties b/TMP/eclipse-junit-tests/src/main/resources/label.properties
index 5cc35aef2..81c91a842 100644
--- a/TMP/eclipse-junit-tests/src/main/resources/label.properties
+++ b/TMP/eclipse-junit-tests/src/main/resources/label.properties
@@ -1,4 +1,5 @@
-timestamp=201112091447
+# can't access timestamp, so use version qualifier instead
+timestamp=${buildQualifier}
buildType=I
-buildId=I20111209-1447
-buildLabel=I20111209-1447
+buildId=${buildQualifier}
+buildLabel=${buildQualifier}
diff --git a/maven-cbi-plugin/.gitignore b/maven-cbi-plugin/.gitignore
new file mode 100644
index 000000000..aba6df246
--- /dev/null
+++ b/maven-cbi-plugin/.gitignore
@@ -0,0 +1,5 @@
+.project
+.classpath
+.settings/
+target/
+bin/
diff --git a/maven-cbi-plugin/pom.xml b/maven-cbi-plugin/pom.xml
new file mode 100644
index 000000000..e9904fcbc
--- /dev/null
+++ b/maven-cbi-plugin/pom.xml
@@ -0,0 +1,53 @@
+<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.1-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <properties>
+ <maven.version>3.0</maven.version>
+ <tycho.version>0.14.0-SNAPSHOT</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>
+
+</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
new file mode 100644
index 000000000..95496c963
--- /dev/null
+++ b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/AbstractPluginScannerMojo.java
@@ -0,0 +1,74 @@
+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;
+
+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 )
+ {
+ OsgiManifest manifest = bundleReader.loadManifest( plugin );
+ manifests.put( plugin, manifest );
+ }
+
+ 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/PluginVersionsMojo.java b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/PluginVersionsMojo.java
new file mode 100644
index 000000000..ca25c7a95
--- /dev/null
+++ b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/PluginVersionsMojo.java
@@ -0,0 +1,32 @@
+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
new file mode 100644
index 000000000..fa49c970e
--- /dev/null
+++ b/maven-cbi-plugin/src/main/java/org/eclipse/cbi/mojo/TestPropertiesMojo.java
@@ -0,0 +1,207 @@
+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();
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index e3d4b785d..ae800d5e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,6 +11,7 @@
<modules>
<module>eclipse-parent</module>
+ <module>maven-cbi-plugin</module>
<module>eclipse.jdt/</module>
<module>eclipse.jdt.core</module>

Back to the top