From: <my...@us...> - 2009-07-21 23:56:29
|
Revision: 2012 http://aperture.svn.sourceforge.net/aperture/?rev=2012&view=rev Author: mylka Date: 2009-07-21 23:56:19 +0000 (Tue, 21 Jul 2009) Log Message: ----------- 2824895 - an eclipse-friendly assembly, created a maven plugin that copies creates an assembly where all jars have the same name as the symbolic name of the bundles they contain Modified Paths: -------------- aperture/trunk/assembly/aperture-jars/pom.xml aperture/trunk/assembly/example-jars/pom.xml aperture/trunk/assembly/optional-libs/pom.xml aperture/trunk/assembly/pom.xml aperture/trunk/assembly/required-libs/pom.xml aperture/trunk/pom.xml Added Paths: ----------- aperture/trunk/assembly/eclipse/ aperture/trunk/assembly/eclipse/pom.xml aperture/trunk/assembly/eclipse/src/ aperture/trunk/assembly/eclipse/src/main/ aperture/trunk/assembly/eclipse/src/main/assembly/ aperture/trunk/assembly/eclipse/src/main/assembly/eclipse.xml aperture/trunk/assembly/maven-plugin/ aperture/trunk/assembly/maven-plugin/pom.xml aperture/trunk/assembly/maven-plugin/src/ aperture/trunk/assembly/maven-plugin/src/main/ aperture/trunk/assembly/maven-plugin/src/main/java/ aperture/trunk/assembly/maven-plugin/src/main/java/org/ aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/ aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/aperture/ aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/aperture/assemblymojo/ aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/aperture/assemblymojo/EclipseAssemblyMojo.java Modified: aperture/trunk/assembly/aperture-jars/pom.xml =================================================================== --- aperture/trunk/assembly/aperture-jars/pom.xml 2009-07-16 16:10:01 UTC (rev 2011) +++ aperture/trunk/assembly/aperture-jars/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -37,10 +37,11 @@ <inherited>false</inherited> <executions> <execution> - <id>generate-release</id> + <id>generate-release-sdk</id> <phase>package</phase> <goals> <goal>single</goal> + <goal>directory-single</goal> </goals> <configuration> <finalName>aperture-${project.version}</finalName> @@ -51,6 +52,24 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-maven-plugin</artifactId> + <inherited>false</inherited> + <executions> + <execution> + <id>generate-release-sdk</id> + <phase>package</phase> + <goals> + <goal>eclipse-package</goal> + </goals> + <configuration> + <folder>${basedir}/target/aperture-${project.version}-sdk</folder> + <outputFolder>${basedir}/target</outputFolder> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </project> Added: aperture/trunk/assembly/eclipse/pom.xml =================================================================== --- aperture/trunk/assembly/eclipse/pom.xml (rev 0) +++ aperture/trunk/assembly/eclipse/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -0,0 +1,85 @@ +<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> + <description>Produces the Aperture Release Artifacts</description> + + <parent> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture</artifactId> + <version>1.3.0-SNAPSHOT</version> + </parent> + + <artifactId>aperture-assembly-main-eclipse</artifactId> + <packaging>pom</packaging> + <dependencies> + <dependency> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-aperture-jars</artifactId> + <classifier>eclipse</classifier> + <version>${aperture.version}</version> + <type>zip</type> + </dependency> + <dependency> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-example-jars</artifactId> + <version>${aperture.version}</version> + <classifier>eclipse</classifier> + <type>zip</type> + </dependency> + <dependency> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-required-libs</artifactId> + <version>${aperture.version}</version> + <classifier>eclipse</classifier> + <type>zip</type> + </dependency> + <dependency> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-optional-libs</artifactId> + <version>${aperture.version}</version> + <classifier>eclipse</classifier> + <type>zip</type> + </dependency> + </dependencies> + + <name>Aperture Main Eclipse Release assembly</name> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <inherited>false</inherited> + <executions> + <execution> + <id>generate-release</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <finalName>aperture-${project.version}</finalName> + <descriptors> + <descriptor>src/main/assembly/eclipse.xml</descriptor> + </descriptors> + </configuration> + </execution> + <execution> + <id>generate-releasefolder</id> + <phase>package</phase> + <goals> + <goal>directory-single</goal> + </goals> + <configuration> + <finalName>aperture-${project.version}</finalName> + <descriptors> + <descriptor>src/main/assembly/eclipse.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Property changes on: aperture/trunk/assembly/eclipse/pom.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: aperture/trunk/assembly/eclipse/src/main/assembly/eclipse.xml =================================================================== --- aperture/trunk/assembly/eclipse/src/main/assembly/eclipse.xml (rev 0) +++ aperture/trunk/assembly/eclipse/src/main/assembly/eclipse.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -0,0 +1,87 @@ +<assembly> + <id>eclipse</id> + + <formats> + <format>tar.gz</format> + <format>zip</format> + </formats> + + <archiverConfig> + <duplicateBehavior>skip</duplicateBehavior> + </archiverConfig> + + <baseDirectory>aperture-${project.version}</baseDirectory> + + <dependencySets> + <dependencySet> + <useProjectArtifact>false</useProjectArtifact> + <useTransitiveDependencies>false</useTransitiveDependencies> + <outputDirectory>/</outputDirectory> + <unpack>true</unpack> + </dependencySet> + + </dependencySets> + + <files> + <file> + <source>../../LICENSE.txt</source> + <outputDirectory/> + </file> + <file> + <source>../../README.txt</source> + <outputDirectory/> + </file> + </files> + + <fileSets> + <!-- + this fileset didn't work with the 2.2-beta-3 version of the assembly plugin + on my ubuntu machine, it failed with an error + org.codehaus.plexus.archiver.ArchiverException: Failed to retrieve numeric file attributes using: '/bin/sh -c ls -1nlaR /' + which seems to be known: + http://www.mail-archive.com/us...@ma.../msg96162.html + tried downgrading to 2.2-beta-2, but which solved this problem, but yielded the assembly + unusable due to: http://jira.codehaus.org/browse/MASSEMBLY-285 + that's why I resorted to the <files> section above --> + <!-- + <fileSet> + <outputDirectory/> + <includes> + <include>*.txt</include> + </includes> + </fileSet> + --> + <fileSet> + <directory>../../src/main/licenses</directory> + <outputDirectory>lib</outputDirectory> + </fileSet> + <fileSet> + <directory>../../target/site/apidocs</directory> + <outputDirectory>apidocs</outputDirectory> + </fileSet> + <fileSet> + <directory>../../target</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>*src.zip</include> + </includes> + </fileSet> + <fileSet> + <directory>../../src/main/bin</directory> + <outputDirectory>bin</outputDirectory> + <includes> + <include>*.sh</include> + </includes> + <lineEnding>unix</lineEnding> + <fileMode>0744</fileMode> + </fileSet> + <fileSet> + <directory>../../src/main/bin</directory> + <includes> + <include>*.bat</include> + </includes> + <outputDirectory>bin</outputDirectory> + <lineEnding>dos</lineEnding> + </fileSet> + </fileSets> +</assembly> Property changes on: aperture/trunk/assembly/eclipse/src/main/assembly/eclipse.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: aperture/trunk/assembly/example-jars/pom.xml =================================================================== --- aperture/trunk/assembly/example-jars/pom.xml 2009-07-16 16:10:01 UTC (rev 2011) +++ aperture/trunk/assembly/example-jars/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -40,6 +40,7 @@ <phase>package</phase> <goals> <goal>single</goal> + <goal>directory-single</goal> </goals> <configuration> <finalName>aperture-${project.version}</finalName> @@ -50,6 +51,24 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-maven-plugin</artifactId> + <inherited>false</inherited> + <executions> + <execution> + <id>generate-release-sdk</id> + <phase>package</phase> + <goals> + <goal>eclipse-package</goal> + </goals> + <configuration> + <folder>${basedir}/target/aperture-${project.version}-sdk</folder> + <outputFolder>${basedir}/target</outputFolder> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </project> Added: aperture/trunk/assembly/maven-plugin/pom.xml =================================================================== --- aperture/trunk/assembly/maven-plugin/pom.xml (rev 0) +++ aperture/trunk/assembly/maven-plugin/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -0,0 +1,35 @@ +<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> + + <parent> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly</artifactId> + <version>1.3.0-SNAPSHOT</version> + </parent> + + <artifactId>aperture-assembly-maven-plugin</artifactId> + <packaging>maven-plugin</packaging> + + <name>Aperture Assembly: - Maven plugin</name> + <description>Plugin to generate an eclipse-friendly version of a maven assembly</description> + + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-project</artifactId> + </dependency> + + <dependency> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-util</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file Property changes on: aperture/trunk/assembly/maven-plugin/pom.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/aperture/assemblymojo/EclipseAssemblyMojo.java =================================================================== --- aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/aperture/assemblymojo/EclipseAssemblyMojo.java (rev 0) +++ aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/aperture/assemblymojo/EclipseAssemblyMojo.java 2009-07-21 23:56:19 UTC (rev 2012) @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2006 - 2009 Aduna and Deutsches Forschungszentrum fuer Kuenstliche Intelligenz DFKI GmbH. + * All rights reserved. + * + * Licensed under the Aperture BSD-style license. + */ +package org.semanticdesktop.aperture.assemblymojo; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectHelper; +import org.semanticdesktop.aperture.util.IOUtil; + +/** + * @goal eclipse-package + * @phase package + */ +public class EclipseAssemblyMojo extends AbstractMojo { + + /** + * @parameter + */ + private String folder; + + /** + * @parameter + */ + private String outputFolder; + + /** + * Maven ProjectHelper. + * + * @component + */ + private MavenProjectHelper projectHelper; + + /** + * @parameter default-value="${project}" + * @required + * @readonly + */ + private MavenProject project; + + public void execute() + throws MojoExecutionException + { + File folderFile = new File(folder).getAbsoluteFile(); + if (!folderFile.exists()) { + throw new MojoExecutionException("folder: " + folder + " doesn't exist"); + } + if (!folderFile.isDirectory()) { + throw new MojoExecutionException("folder: " + folder + " is not a folder"); + } + String folderName = folderFile.getName(); + + File parentFolder = folderFile.getParentFile(); + + int dashIndex = folderName.lastIndexOf("-"); + String noClassifierName = null; + if (dashIndex == -1) { + noClassifierName = folderName; + } else { + noClassifierName = folderName.substring(0,dashIndex); + } + + String zipFileName = outputFolder + "/" + noClassifierName + "-eclipse.zip"; + File zipFile = new File(zipFileName); + zipFile.delete(); + try { + createZipFile(zipFileName,folderFile,noClassifierName + "-eclipse"); + } catch (Exception e) { + throw new MojoExecutionException("couldn't create a zip file",e); + } + + projectHelper.attachArtifact(project,"zip","eclipse",zipFile); + + } + + private void createZipFile(String zipFileName, File folderFile, String parentPath) throws IOException { + FileOutputStream fos = new FileOutputStream(zipFileName); + ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos)); + addFolder(zos,folderFile,""); + zos.close(); + } + + private void addFolder(ZipOutputStream zos, File folderFile, String path) throws IOException { + String [] children = folderFile.list(); + for (String child : children) { + File childFile = new File(folderFile,child); + if (childFile.isDirectory()) { + addFolder(zos, childFile, path + child + "/"); + } else if (childFile.isFile()) { + addFile(zos, childFile, path); + } + } + } + + private void addFile(ZipOutputStream zos, File childFile, String parentFolderName) throws IOException { + if (!childFile.getName().endsWith(".jar")) { + putEntry(zos, childFile, parentFolderName, childFile.getName()); + } else { + JarFile jarFile = new JarFile(childFile); + Attributes attrs = jarFile.getManifest().getMainAttributes(); + String symbolicName = (String)attrs.getValue("Bundle-SymbolicName"); + if (symbolicName == null) { + putEntry(zos, childFile, parentFolderName, childFile.getName()); + } else { + String version = (String)attrs.getValue("Bundle-Version"); + if (version != null) { + putEntry(zos, childFile, parentFolderName, symbolicName + "_" + version + ".jar"); + } else { + putEntry(zos, childFile, parentFolderName, symbolicName + ".jar"); + } + } + } + } + + private void putEntry(ZipOutputStream zos, File childFile, String parentFolderName, String fileName) throws IOException { + ZipEntry entry = new ZipEntry(parentFolderName + "/" + fileName); + zos.putNextEntry(entry); + IOUtil.writeStream(new BufferedInputStream(new FileInputStream(childFile)), zos); + zos.closeEntry(); + } +} Property changes on: aperture/trunk/assembly/maven-plugin/src/main/java/org/semanticdesktop/aperture/assemblymojo/EclipseAssemblyMojo.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: aperture/trunk/assembly/optional-libs/pom.xml =================================================================== --- aperture/trunk/assembly/optional-libs/pom.xml 2009-07-16 16:10:01 UTC (rev 2011) +++ aperture/trunk/assembly/optional-libs/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -36,6 +36,7 @@ <phase>package</phase> <goals> <goal>single</goal> + <goal>directory-single</goal> </goals> <configuration> <finalName>aperture-${project.version}</finalName> @@ -46,6 +47,24 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-maven-plugin</artifactId> + <inherited>false</inherited> + <executions> + <execution> + <id>generate-release-sdk</id> + <phase>package</phase> + <goals> + <goal>eclipse-package</goal> + </goals> + <configuration> + <folder>${basedir}/target/aperture-${project.version}-sdk</folder> + <outputFolder>${basedir}/target</outputFolder> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </project> Modified: aperture/trunk/assembly/pom.xml =================================================================== --- aperture/trunk/assembly/pom.xml 2009-07-16 16:10:01 UTC (rev 2011) +++ aperture/trunk/assembly/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -18,10 +18,12 @@ <description>Assemblies generated for the aperture release</description> <modules> + <module>maven-plugin</module> <module>aperture-jars</module> <module>example-jars</module> <module>optional-libs</module> <module>required-libs</module> <module>main</module> + <module>eclipse</module> </modules> </project> Modified: aperture/trunk/assembly/required-libs/pom.xml =================================================================== --- aperture/trunk/assembly/required-libs/pom.xml 2009-07-16 16:10:01 UTC (rev 2011) +++ aperture/trunk/assembly/required-libs/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -36,6 +36,7 @@ <phase>package</phase> <goals> <goal>single</goal> + <goal>directory-single</goal> </goals> <configuration> <finalName>aperture-${project.version}</finalName> @@ -46,6 +47,24 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.semanticdesktop.aperture</groupId> + <artifactId>aperture-assembly-maven-plugin</artifactId> + <inherited>false</inherited> + <executions> + <execution> + <id>generate-release-sdk</id> + <phase>package</phase> + <goals> + <goal>eclipse-package</goal> + </goals> + <configuration> + <folder>${basedir}/target/aperture-${project.version}-sdk</folder> + <outputFolder>${basedir}/target</outputFolder> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </project> Modified: aperture/trunk/pom.xml =================================================================== --- aperture/trunk/pom.xml 2009-07-16 16:10:01 UTC (rev 2011) +++ aperture/trunk/pom.xml 2009-07-21 23:56:19 UTC (rev 2012) @@ -786,7 +786,12 @@ <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> <version>2.0.9</version> - </dependency> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-project</artifactId> + <version>2.0.9</version> + </dependency> </dependencies> </dependencyManagement> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |