You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by dj...@apache.org on 2011/01/28 20:35:55 UTC
svn commit: r1064831 - in /karaf/trunk: ./ tooling/features-maven-plugin/
tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/
tooling/features-maven-plugin/src/main/resources/META-INF/plexus/
Author: djencks
Date: Fri Jan 28 19:35:54 2011
New Revision: 1064831
URL: http://svn.apache.org/viewvc?rev=1064831&view=rev
Log:
KARAF-424 add an ArchiveServerMojo based on the geronimo ArchiveGBean, try it out on assemblies/apache-karaf
Added:
karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java (with props)
Modified:
karaf/trunk/pom.xml
karaf/trunk/tooling/features-maven-plugin/pom.xml
karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveKarMojo.java
karaf/trunk/tooling/features-maven-plugin/src/main/resources/META-INF/plexus/components.xml
Modified: karaf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/pom.xml?rev=1064831&r1=1064830&r2=1064831&view=diff
==============================================================================
--- karaf/trunk/pom.xml (original)
+++ karaf/trunk/pom.xml Fri Jan 28 19:35:54 2011
@@ -690,6 +690,17 @@
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.ant</artifactId>
+ <version>1.7.0_3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.junit</artifactId>
<version>${junit.bundle.version}</version>
</dependency>
Modified: karaf/trunk/tooling/features-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/pom.xml?rev=1064831&r1=1064830&r2=1064831&view=diff
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/pom.xml (original)
+++ karaf/trunk/tooling/features-maven-plugin/pom.xml Fri Jan 28 19:35:54 2011
@@ -90,6 +90,10 @@
<groupId>org.apache.karaf.deployer</groupId>
<artifactId>org.apache.karaf.deployer.kar</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.ant</artifactId>
+ </dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Modified: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveKarMojo.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveKarMojo.java?rev=1064831&r1=1064830&r2=1064831&view=diff
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveKarMojo.java (original)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveKarMojo.java Fri Jan 28 19:35:54 2011
@@ -44,7 +44,7 @@ import org.codehaus.plexus.archiver.jar.
*
* @version $Revision: 1.1 $
* @goal archive-kar
- * @phase compile
+ * @phase package
* @execute phase="package"
* @requiresDependencyResolution runtime
* @inheritByDefault true
@@ -125,7 +125,7 @@ public class ArchiveKarMojo extends Mojo
*
* @parameter default-value="${repositoryPath}"
*/
- private String repositoryPath;
+ private String repositoryPath = "repository/";
//
Added: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java?rev=1064831&view=auto
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java (added)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java Fri Jan 28 19:35:54 2011
@@ -0,0 +1,151 @@
+/*
+ * 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.karaf.tooling.features;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.taskdefs.Tar;
+import org.apache.tools.ant.taskdefs.Zip;
+import org.apache.tools.ant.types.TarFileSet;
+import org.apache.tools.ant.types.ZipFileSet;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Package a server archive from an assembled server
+ *
+ * @version $Revision: 1.1 $
+ * @goal archive-server
+ * @phase package
+ * @execute phase="package"
+ * @requiresDependencyResolution runtime
+ * @inheritByDefault true
+ * @description Package a server archive from an assembled server
+ */
+public class ArchiveServerMojo extends MojoSupport {
+
+ /**
+ * The target directory of the project.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ * @readonly
+ */
+ private File destDir;
+
+
+ /**
+ * The location of the server repository.
+ *
+ * @parameter expression="${project.build.directory}/assembly"
+ * @required
+ */
+ private File targetServerDirectory;
+
+ /**
+ * The target file to set as the project's artifact.
+ *
+ * @parameter expression="${project.file}"
+ * @required
+ */
+ private File targetFile;
+
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().debug("Setting artifact file: " + targetFile);
+ org.apache.maven.artifact.Artifact artifact = project.getArtifact();
+ artifact.setFile(targetFile);
+ try {
+ //now pack up the server.
+ archive("tar.gz");
+ archive("zip");
+ } catch (Exception e) {
+ throw new MojoExecutionException("Could not archive plugin", e);
+ }
+ }
+
+ private void archive(String type) throws IOException {
+ Artifact artifact1 = factory.createArtifactWithClassifier(project.getArtifact().getGroupId(), project.getArtifact().getArtifactId(), project.getArtifact().getVersion(), type, "bin");
+ File target1 = archive(targetServerDirectory, destDir, artifact1);
+ projectHelper.attachArtifact( project, artifact1.getType(), "bin", target1 );
+ }
+
+ public File archive(File source, File dest, Artifact artifact) throws //ArchiverException,
+ IOException {
+ String serverName = artifact.getArtifactId() + "-" + artifact.getVersion();
+ dest = new File(dest, serverName + "-bin." + artifact.getType());
+ Project project = new Project();
+ MatchingTask archiver;
+ if ("tar.gz".equals(artifact.getType())) {
+ Tar tar = new Tar();
+ Tar.TarCompressionMethod tarCompressionMethod = new Tar.TarCompressionMethod();
+ tarCompressionMethod.setValue("gzip");
+ tar.setCompression(tarCompressionMethod);
+ Tar.TarLongFileMode fileMode = new Tar.TarLongFileMode();
+ fileMode.setValue(Tar.TarLongFileMode.GNU);
+ tar.setLongfile(fileMode);
+ tar.setDestFile(dest);
+ TarFileSet rc = new TarFileSet();
+ rc.setDir(source);
+ rc.setPrefix(serverName);
+ rc.setProject(project);
+ rc.setExcludes("bin/");
+ tar.add(rc);
+
+ rc = new TarFileSet();
+ rc.setDir(source);
+ rc.setPrefix(serverName);
+ rc.setProject(project);
+ rc.setIncludes("bin/");
+ rc.setExcludes("bin/*.bat");
+ rc.setFileMode("755");
+ tar.add(rc);
+
+ rc = new TarFileSet();
+ rc.setDir(source);
+ rc.setPrefix(serverName);
+ rc.setProject(project);
+ rc.setIncludes("bin/*.bat");
+ tar.add(rc);
+
+ archiver = tar;
+ } else if ("zip".equals(artifact.getType())) {
+ Zip zip = new Zip();
+ zip.setDestFile(dest);
+ ZipFileSet fs = new ZipFileSet();
+ fs.setDir(source);
+ fs.setPrefix(serverName);
+ fs.setProject(project);
+ zip.addFileset(fs);
+ archiver = zip;
+ } else {
+ throw new IllegalArgumentException("Unknown target type: " + artifact.getType());
+ }
+ archiver.setProject(project);
+ archiver.execute();
+ return dest;
+ }
+
+}
Propchange: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ArchiveServerMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: karaf/trunk/tooling/features-maven-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/tooling/features-maven-plugin/src/main/resources/META-INF/plexus/components.xml?rev=1064831&r1=1064830&r2=1064831&view=diff
==============================================================================
--- karaf/trunk/tooling/features-maven-plugin/src/main/resources/META-INF/plexus/components.xml (original)
+++ karaf/trunk/tooling/features-maven-plugin/src/main/resources/META-INF/plexus/components.xml Fri Jan 28 19:35:54 2011
@@ -106,13 +106,14 @@
<compile>
</compile>
<package>
+ org.apache.karaf.tooling:features-maven-plugin:archive-server
</package>
- <!--<install>-->
- <!--org.apache.maven.plugins:maven-install-plugin:install-->
- <!--</install>-->
- <!--<deploy>-->
- <!--org.apache.maven.plugins:maven-deploy-plugin:deploy-->
- <!--</deploy>-->
+ <install>
+ org.apache.maven.plugins:maven-install-plugin:install
+ </install>
+ <deploy>
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
+ </deploy>
</phases>
</lifecycle>
</lifecycles>