You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2008/08/20 20:43:28 UTC

svn commit: r687418 - in /felix/sandbox/cziegeler/maven-dp-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/felix/ src/main/java/org/apache/felix/maven/ src/main/java/org/apache/felix/maven/...

Author: cziegeler
Date: Wed Aug 20 11:43:27 2008
New Revision: 687418

URL: http://svn.apache.org/viewvc?rev=687418&view=rev
Log:
Add initial version of a maven plugin to generate deployment packages.

Added:
    felix/sandbox/cziegeler/maven-dp-plugin/   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/pom.xml   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/src/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java   (with props)
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/
    felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml   (with props)

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug 20 11:43:27 2008
@@ -0,0 +1 @@
+target

Added: felix/sandbox/cziegeler/maven-dp-plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/pom.xml?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/pom.xml (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/pom.xml Wed Aug 20 11:43:27 2008
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- 
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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. 
+-->
+<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>
+        <artifactId>felix</artifactId>
+        <groupId>org.apache.felix</groupId>
+        <version>1.0.2</version>
+    </parent>
+
+    <groupId>org.apache.felix</groupId>
+    <artifactId>maven-dp-plugin</artifactId>
+
+    <version>0.9.0-SNAPSHOT</version>
+    <packaging>maven-plugin</packaging>
+
+    <name>Maven DP Plugin</name>
+    <description>
+        Maven plugin for generating OSGi deployment packages.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/dpplugin</connection>
+        <developerConnection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/dpplugin</developerConnection>
+        <url>http://svn.apache.org/repos/asf/felix/dpplugin</url>
+    </scm>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>1.1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>1.1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>javax.servlet</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>2.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-artifact</artifactId>
+            <version>2.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-project</artifactId>
+            <version>2.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.4</version>
+        </dependency>
+    </dependencies>
+</project>

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java Wed Aug 20 11:43:27 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.felix.maven.dp;
+
+import java.io.File;
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * Simple bean that collects information about a bundle.
+ */
+public class BundleInfo {
+
+    public String symbolicname;
+    public String bundleVersion;
+    public File   artifactFile;
+    public Artifact artifact;
+
+}
\ No newline at end of file

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/BundleInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java Wed Aug 20 11:43:27 2008
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.felix.maven.dp;
+
+public interface Constants extends org.osgi.framework.Constants {
+
+    // manifest main attribute header constants
+    public static final String DEPLOYMENTPACKAGE_SYMBOLICMAME = "DeploymentPackage-SymbolicName";
+    public static final String DEPLOYMENTPACKAGE_VERSION = "DeploymentPackage-Version";
+    public static final String DEPLOYMENTPACKAGE_FIXPACK = "DeploymentPackage-FixPack";
+
+    // manifest 'name' section header constants
+    public static final String RESOURCE_PROCESSOR = "Resource-Processor";
+    public static final String DEPLOYMENTPACKAGE_MISSING = "DeploymentPackage-Missing";
+    public static final String DEPLOYMENTPACKAGE_CUSTOMIZER = "DeploymentPackage-Customizer";
+
+    // event topics and properties
+    public static final String EVENTTOPIC_INSTALL = "org/osgi/service/deployment/INSTALL";
+    public static final String EVENTTOPIC_UNINSTALL = "org/osgi/service/deployment/UNINSTALL";
+    public static final String EVENTTOPIC_COMPLETE = "org/osgi/service/deployment/COMPLETE";
+    public static final String EVENTPROPERTY_DEPLOYMENTPACKAGE_NAME = "deploymentpackage.name";
+    public static final String EVENTPROPERTY_SUCCESSFUL = "successful";
+
+    // miscellaneous constants
+    public static final String BUNDLE_LOCATION_PREFIX = "osgi-dp:";
+}
\ No newline at end of file

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/Constants.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java Wed Aug 20 11:43:27 2008
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.felix.maven.dp;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.felix.maven.dp.om.BundleResource;
+import org.apache.felix.maven.dp.om.DeploymentPackageInfo;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+
+
+/**
+ * @goal dp
+ * @phase package
+ * @requiresDependencyResolution test
+ * @description Create an OSGi deployment package
+ *
+ * @version $Rev$, $Date$
+ */
+public class PackagerMojo extends org.apache.maven.plugin.AbstractMojo {
+
+    /**
+     * The Maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    protected MavenProject project;
+
+    /**
+     * Directory containing the generated JAR.
+     *
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    private File outputDirectory;
+
+    /**
+     * Name of the generated JAR.
+     *
+     * @parameter alias="jarName" expression="${jar.finalName}" default-value="${project.build.finalName}"
+     * @required
+     */
+    private String finalName;
+
+    /**
+     * @component
+     */
+    private ArtifactHandlerManager artifactHandlerManager;
+
+    /**
+     * @see org.apache.maven.plugin.Mojo#execute()
+     */
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        // create package info
+        final DeploymentPackageInfo pck = new DeploymentPackageInfo();
+
+        // set default values
+        pck.setSymbolicName(this.project.getGroupId() + '.' + this.project.getArtifactId());
+        pck.setVersion(this.project.getVersion());
+        pck.setDescription(this.project.getDescription());
+
+        // collect bundles
+        this.getLog().info("Collecting all bundles...");
+        final Map resolved = this.project.getArtifactMap();
+        final Set artifacts = this.project.getDependencyArtifacts();
+        final Iterator i = artifacts.iterator();
+        while ( i.hasNext() ) {
+            final Artifact artifact = (Artifact) i.next();
+            final BundleInfo info = this.checkArtifact(artifact, resolved);
+            if ( info != null ) {
+                this.getLog().info("Found bundle " + info.symbolicname + ":" + info.bundleVersion);
+                pck.addBundleResource(new BundleResource(info));
+            }
+        }
+
+        // write jar file
+        this.createJarFile(pck);
+    }
+
+    private void createJarFile(final DeploymentPackageInfo pck)
+    throws MojoExecutionException {
+        this.outputDirectory.mkdirs();
+        final File jarFile = new File( this.outputDirectory, this.finalName + ".dp" );
+
+        this.getLog().info("Write deployment package to " + jarFile);
+
+        FileOutputStream jfos = null;
+        JarOutputStream jos = null;
+        try {
+            // manifest
+            final Manifest mf = new Manifest();
+            addManifestEntry(mf, Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
+
+            addManifestEntry(mf, "DeploymentPackage-ManifestVersion", "1.0");
+            addManifestEntry(mf, "Content-Type", "application/vnd.osgi.dp");
+
+            addManifestEntry(mf, Constants.DEPLOYMENTPACKAGE_SYMBOLICMAME, pck.getSymbolicName());
+            addManifestEntry(mf, Constants.DEPLOYMENTPACKAGE_VERSION, pck.getVersion());
+
+            addManifestEntry(mf, "DeploymentPackage-Description", pck.getDescription());
+
+            // create entries for bundles
+            final Iterator bI = pck.getBundleResources().iterator();
+            while ( bI.hasNext() ) {
+                final BundleResource rsrc = (BundleResource) bI.next();
+                // add new entry
+                final Attributes attr = new Attributes();
+                addAttr(attr, Constants.BUNDLE_SYMBOLICNAME, rsrc.getSymbolicName());
+                addAttr(attr, Constants.BUNDLE_VERSION, rsrc.getVersion());
+                mf.getEntries().put(rsrc.getId(), attr);
+            }
+
+            jfos = new FileOutputStream(jarFile);
+            jos = new JarOutputStream(jfos, mf);
+
+            final Iterator bundleIterator = pck.getBundleResources().iterator();
+            while ( bundleIterator.hasNext() ) {
+                final BundleResource rsrc = (BundleResource) bundleIterator.next();
+                final JarEntry je = new JarEntry(rsrc.getId());
+                jos.putNextEntry(je);
+                IOUtils.copy(rsrc.getInputStream(), jos);
+                jos.closeEntry();
+            }
+            jos.flush();
+        } catch (IOException ioe) {
+            throw new MojoExecutionException("Unable to write javadoc bundle file", ioe);
+        } finally {
+            IOUtils.closeQuietly(jos);
+            IOUtils.closeQuietly(jfos);
+        }
+        this.project.getArtifact().setFile(jarFile);
+    }
+
+    private void addAttr(final Attributes a, final String name, final String value) {
+        a.put(new Attributes.Name(name), value);
+    }
+
+    private void addManifestEntry(final Manifest mf, final String name, final String value) {
+        mf.getMainAttributes().put(new Attributes.Name(name), value);
+    }
+
+    /**
+     * Check if the artifact is a java artifact (jar or bundle)
+     */
+    protected boolean isJavaArtifact(Artifact artifact) {
+        if ( "jar".equals(artifact.getType()) ) {
+            return true;
+        }
+        if ( "bundle".equals(artifact.getType()) ) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Get the manifest from the artifact.
+     * @param artifact
+     * @return
+     * @throws IOException
+     */
+    protected Manifest getManifest(Artifact artifact) throws IOException {
+        JarFile file = null;
+        try {
+            file = new JarFile(artifact.getFile());
+            return file.getManifest();
+        } finally {
+            if (file != null) {
+                try {
+                    file.close();
+                } catch (IOException ignore) {
+                }
+            }
+        }
+    }
+
+    protected BundleInfo checkArtifact(final Artifact declared, Map resolved)
+    throws MojoExecutionException {
+        this.getLog().info("  Processing artifact " + declared);
+        if (declared.getScope() == null
+            || Artifact.SCOPE_COMPILE.equals(declared.getScope())
+            || Artifact.SCOPE_PROVIDED.equals(declared.getScope())
+            || Artifact.SCOPE_RUNTIME.equals(declared.getScope())) {
+            this.getLog().debug("    Resolving artifact " + declared);
+            final Artifact artifact = (declared.isResolved() ? declared : (Artifact) resolved.get(ArtifactUtils.versionlessKey(declared)));
+            if ( artifact == null ) {
+                throw new MojoExecutionException("Unable to resolve artifact " + declared);
+            } else if ( this.isJavaArtifact(artifact) ) {
+                this.getLog().debug("    Getting manifest from artifact " + artifact);
+                try {
+                    final Manifest m = this.getManifest(artifact);
+                    if (m != null ) {
+                        final String name = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+                        if ( name != null ) {
+                            this.getLog().debug("    Found bundle: " + artifact.getArtifactId() + " with name " + name);
+                            final BundleInfo info = new BundleInfo();
+                            info.symbolicname = name;
+                            info.bundleVersion = m.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
+                            info.artifactFile = artifact.getFile();
+                            info.artifact = artifact;
+                            return info;
+                        }
+                    } else {
+                        this.getLog().debug("    Unable to get manifest from artifact " + artifact);
+                    }
+                } catch (IOException ioe) {
+                    throw new MojoExecutionException("Unable to get manifest from artifact " + artifact, ioe);
+                }
+            } else {
+                this.getLog().debug("    Artifact is not a Java artifact " + declared);
+            }
+        } else {
+            this.getLog().debug("    Artifact " + declared + " has not scope compile, provided or runtime, but: " + declared.getScope());
+        }
+        return null;
+    }
+}

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/PackagerMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java Wed Aug 20 11:43:27 2008
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.felix.maven.dp.om;
+
+/**
+ * Abstract class used by all resources.
+ */
+public class AbstractResource {
+
+    /** The target path in the package. */
+    private String targetPath;
+
+    /** The resource name. */
+    private String name;
+
+    /**
+     * @return The resource name.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Set the name
+     * @param value New name
+     */
+    public void setName(final String value) {
+        this.name = value;
+    }
+
+    /**
+     * @return the targetPath
+     */
+    public String getTargetPath() {
+        return targetPath;
+    }
+
+    /**
+     * Set the target path.
+     * @param value The target path.
+     */
+    public void setTargetPath(final String value) {
+        targetPath = value;
+    }
+
+    /**
+     * Return the unique id of this resource
+     * @return The id of the resource is the target path + '/' + name
+     *         or just name if target path is empty.
+     */
+    public String getId() {
+        if (targetPath != null && targetPath.length() > 0) {
+             return targetPath + "/" + name;
+        }
+        return name;
+    }
+
+}

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/AbstractResource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java Wed Aug 20 11:43:27 2008
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.felix.maven.dp.om;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.felix.maven.dp.BundleInfo;
+
+
+/**
+ * Description of a bundle resource.
+ */
+public class BundleResource extends AbstractResource {
+
+    private BundleInfo info;
+
+    public BundleResource(final BundleInfo info) {
+        this.setName(info.symbolicname + "-" + info.bundleVersion + ".jar");
+        this.setTargetPath("bundles");
+        this.info = info;
+    }
+
+    public String getSymbolicName() {
+        return info.symbolicname;
+    }
+
+    public String getVersion() {
+        return info.bundleVersion;
+    }
+
+    public InputStream getInputStream()
+    throws IOException {
+        return new FileInputStream(info.artifactFile);
+    }
+}

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/BundleResource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java Wed Aug 20 11:43:27 2008
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.felix.maven.dp.om;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Description of a content package
+ */
+public class DeploymentPackageInfo {
+
+    /** Symbolic name (required). */
+    private String symbolicName;
+
+    /** Package version (required). */
+    private String version;
+
+    /** Copyright information. */
+    private String copyright;
+
+    /** Optional description. */
+    private String description;
+
+    /** contact address. */
+    private String contactAddress;
+
+    /** documentation url */
+    private String docUrl;
+
+    /** Vendor information */
+    private String vendor;
+
+    /** License url */
+    private String licenseUrl;
+
+    /** List of bundle resources. */
+    private final List bundleResources = new ArrayList();
+
+    public String getSymbolicName() {
+        return symbolicName;
+    }
+
+    public void setSymbolicName(String symbolicName) {
+        this.symbolicName = symbolicName;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public String getCopyright() {
+        return copyright;
+    }
+
+    public void setCopyright(String copyright) {
+        this.copyright = copyright;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getContactAddress() {
+        return contactAddress;
+    }
+
+    public void setContactAddress(String contactAddress) {
+        this.contactAddress = contactAddress;
+    }
+
+    public String getDocUrl() {
+        return docUrl;
+    }
+
+    public void setDocUrl(String docUrl) {
+        this.docUrl = docUrl;
+    }
+
+    public String getVendor() {
+        return vendor;
+    }
+
+    public void setVendor(String vendor) {
+        this.vendor = vendor;
+    }
+
+    public String getLicenseUrl() {
+        return licenseUrl;
+    }
+
+    public void setLicenseUrl(String licenseUrl) {
+        this.licenseUrl = licenseUrl;
+    }
+
+    /**
+     * Get the list of bundle resources.
+     * @return The bundle resources.
+     */
+    public final List getBundleResources() {
+        return this.bundleResources;
+    }
+
+    public void addBundleResource(final BundleResource resource) {
+        this.bundleResources.add(resource);
+    }
+}

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/java/org/apache/felix/maven/dp/om/DeploymentPackageInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml?rev=687418&view=auto
==============================================================================
--- felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml (added)
+++ felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml Wed Aug 20 11:43:27 2008
@@ -0,0 +1,62 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+      <role-hint>dp</role-hint>
+      <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+      <configuration>
+        <lifecycles>
+          <lifecycle>
+            <id>default</id>
+            <!-- START SNIPPET: bundle-lifecycle -->
+            <phases>
+              <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
+              <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
+              <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
+              <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
+              <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
+              <package>org.apache.felix:maven-dp-plugin:dp</package>
+              <install>
+                org.apache.maven.plugins:maven-install-plugin:install
+              </install>
+              <deploy>
+                org.apache.maven.plugins:maven-deploy-plugin:deploy
+              </deploy>
+            </phases>
+            <!-- END SNIPPET: bundle-lifecycle -->
+          </lifecycle>
+        </lifecycles>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>dp</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>dp</type>
+        <includesDependencies>true</includesDependencies>
+        <language>java</language>
+        <extension>dp</extension>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+  </components>
+</component-set>

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: felix/sandbox/cziegeler/maven-dp-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain