You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2010/08/01 00:06:31 UTC

svn commit: r981095 - in /axis/axis2/java/core/trunk: ./ modules/metadata/ modules/parent/ modules/tool/axis2-repo-maven-plugin/ modules/tool/axis2-repo-maven-plugin/src/ modules/tool/axis2-repo-maven-plugin/src/main/ modules/tool/axis2-repo-maven-plug...

Author: veithen
Date: Sat Jul 31 22:06:30 2010
New Revision: 981095

URL: http://svn.apache.org/viewvc?rev=981095&view=rev
Log:
Added a new Maven plugin that creates Axis2 repositories based on project dependencies (of type aar and mar). Purpose:
* Get rid of some obscure maven-antrun-plugin, maven-dependency-plugin and maven-assembly-plugin stuff.
* Make sure that modules properly declare their dependencies (instead of copying stuff from the target folder of another module).

Used that plugin to fix the metadata module (which didn't declare its dependency on addressing.mar).

Added:
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/pom.xml   (with props)
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java   (with props)
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java   (with props)
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java   (with props)
Removed:
    axis/axis2/java/core/trunk/modules/metadata/build.xml
Modified:
    axis/axis2/java/core/trunk/modules/metadata/pom.xml
    axis/axis2/java/core/trunk/modules/parent/pom.xml
    axis/axis2/java/core/trunk/pom.xml

Modified: axis/axis2/java/core/trunk/modules/metadata/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/pom.xml?rev=981095&r1=981094&r2=981095&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/metadata/pom.xml Sat Jul 31 22:06:30 2010
@@ -110,6 +110,13 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>addressing</artifactId>
+            <version>${project.version}</version>
+            <type>mar</type>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/metadata</connection>
@@ -187,6 +194,22 @@
                 </configuration>
             </plugin>
             <plugin>
+                <groupId>org.apache.axis2</groupId>
+                <artifactId>axis2-repo-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>create-test-repository</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/repository</outputDirectory>
+                            <axis2xml>../kernel/conf/axis2.xml</axis2xml>
+                            <configurationDirectory>conf</configurationDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
@@ -232,8 +255,6 @@
                                         <include name="org/apache/axis2/jaxws/description/HandlerConfigFile.xml" />
                                     </fileset>
                                 </copy>
-                                <property name="addressing_version" value="${project.version}" />
-                                <ant antfile="build.xml" inheritall="true" inheritrefs="true" dir="." target="build-repo" />
                             </tasks>
                         </configuration>
                         <goals>

Modified: axis/axis2/java/core/trunk/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/parent/pom.xml?rev=981095&r1=981094&r2=981095&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/parent/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/parent/pom.xml Sat Jul 31 22:06:30 2010
@@ -1253,6 +1253,14 @@
                     <artifactId>axis2-mar-maven-plugin</artifactId>
                     <version>1.5.2-SNAPSHOT</version>
                 </plugin>
+                
+                <!-- No chicken and egg problem here because the plugin doesn't expose
+                     any extension. We can always use the version from the current build. -->
+                <plugin>
+                    <groupId>org.apache.axis2</groupId>
+                    <artifactId>axis2-repo-maven-plugin</artifactId>
+                    <version>${project.version}</version>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>

Added: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/pom.xml?rev=981095&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/pom.xml (added)
+++ axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/pom.xml Sat Jul 31 22:06:30 2010
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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>
+        <groupId>org.apache.axis2</groupId>
+        <artifactId>axis2-parent</artifactId>
+        <version>SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+    <artifactId>axis2-repo-maven-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+    <name>Apache Axis2 - tool - Repository Maven Plugin</name>
+    <description>
+        A Maven 2 plugin for creating Axis 2 repositories from project dependencies
+    </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.apache.maven.shared</groupId>
+            <artifactId>maven-common-artifact-filters</artifactId>
+            <version>1.2</version>
+        </dependency>
+    </dependencies>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin</developerConnection>
+        <url>http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin</url>
+    </scm>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-remote-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>process</goal>
+                        </goals>
+                        <configuration>
+                            <resourceBundles>
+                                <resourceBundle>org.apache.axis2:axis2-resource-bundle:${pom.version}</resourceBundle>
+                            </resourceBundles>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <version>2.6</version>
+            </plugin>
+        </plugins>
+    </reporting>
+</project>

Propchange: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java?rev=981095&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java (added)
+++ axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java Sat Jul 31 22:06:30 2010
@@ -0,0 +1,118 @@
+/*
+ * 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.axis2.maven2.repo;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+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.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
+import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
+import org.codehaus.plexus.util.FileUtils;
+
+public abstract class AbstractCreateRepositoryMojo extends AbstractMojo {
+    /**
+     * @parameter expression="${project}"
+     * @readonly
+     * @required
+     */
+    private MavenProject project;
+    
+    /**
+     * The directory (relative to the repository root) where AAR files are copied. This should be
+     * set to the same value as the <tt>ServicesDirectory</tt> property in <tt>axis2.xml</tt>.
+     * 
+     * @parameter default-value="services"
+     */
+    private String servicesDirectory;
+    
+    /**
+     * The directory (relative to the repository root) where MAR files are copied. This should be
+     * set to the same value as the <tt>ModulesDirectory</tt> property in <tt>axis2.xml</tt>.
+     * 
+     * @parameter default-value="modules"
+     */
+    private String modulesDirectory;
+    
+    /**
+     * The <tt>axis2.xml</tt> file to be copied into the repository.
+     * 
+     * @parameter
+     */
+    private File axis2xml;
+    
+    /**
+     * The directory (relative to the repository root) where the <tt>axis2.xml</tt> file will be
+     * copied. If this parameter is not set, then the file will be copied into the repository
+     * root.
+     * 
+     * @parameter
+     */
+    private String configurationDirectory;
+    
+    protected abstract String getScope();
+    
+    protected abstract File getOutputDirectory();
+
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        Set artifacts = project.getArtifacts();
+        FilterArtifacts filter = new FilterArtifacts();
+        filter.addFilter(new ScopeFilter(getScope(), null));
+        filter.addFilter(new TypeFilter("aar,mar", null));
+        try {
+            artifacts = filter.filter(artifacts);
+        } catch (ArtifactFilterException ex) {
+            throw new MojoExecutionException(ex.getMessage(), ex);
+        }
+        File outputDirectory = getOutputDirectory();
+        File servicesDirectory = new File(outputDirectory, this.servicesDirectory);
+        File modulesDirectory = new File(outputDirectory, this.modulesDirectory);
+        for (Iterator it = artifacts.iterator(); it.hasNext(); ) {
+            Artifact artifact = (Artifact)it.next();
+            String type = artifact.getType();
+            String destFileName = artifact.getArtifactId() + "-" + artifact.getVersion() + "." + type;
+            File targetDir = type.equals("mar") ? modulesDirectory : servicesDirectory;
+            getLog().info("Adding " + destFileName);
+            try {
+                FileUtils.copyFile(artifact.getFile(), new File(targetDir, destFileName));
+            } catch (IOException ex) {
+                throw new MojoExecutionException("Error copying " + destFileName + ": " + ex.getMessage(), ex);
+            }
+        }
+        if (axis2xml != null) {
+            getLog().info("Copying axis2.xml");
+            File targetDirectory = configurationDirectory == null
+                    ? outputDirectory : new File(outputDirectory, configurationDirectory);
+            try {
+                FileUtils.copyFile(axis2xml, new File(targetDirectory, "axis2.xml"));
+            } catch (IOException ex) {
+                throw new MojoExecutionException("Error copying axis2.xml file: " + ex.getMessage(), ex);
+            }
+        }
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java?rev=981095&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java (added)
+++ axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java Sat Jul 31 22:06:30 2010
@@ -0,0 +1,50 @@
+/*
+ * 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.axis2.maven2.repo;
+
+import java.io.File;
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * Creates an Axis2 repository from the project's runtime dependencies.
+ * 
+ * @goal create-repository
+ * @phase generate-resources
+ * @requiresDependencyResolution runtime
+ */
+public class CreateRepositoryMojo extends AbstractCreateRepositoryMojo {
+    /**
+     * The output directory where the repository will be created.
+     * 
+     * @parameter default-value="${project.build.directory}/repository"
+     */
+    private File outputDirectory;
+    
+    @Override
+    protected String getScope() {
+        return Artifact.SCOPE_RUNTIME;
+    }
+
+    @Override
+    protected File getOutputDirectory() {
+        return outputDirectory;
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java?rev=981095&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java (added)
+++ axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java Sat Jul 31 22:06:30 2010
@@ -0,0 +1,68 @@
+/*
+ * 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.axis2.maven2.repo;
+
+import java.io.File;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Creates an Axis2 repository from the project's dependencies in scope test. Note that this goal
+ * is skipped if the <code>maven.test.skip</code> property is set to <code>true</code>.
+ * 
+ * @goal create-test-repository
+ * @phase generate-test-resources
+ * @requiresDependencyResolution test
+ */
+public class CreateTestRepositoryMojo extends AbstractCreateRepositoryMojo {
+    /**
+     * The output directory where the repository will be created.
+     * 
+     * @parameter default-value="${project.build.directory}/test-repository"
+     */
+    private File outputDirectory;
+    
+    /**
+     * @parameter expression="${maven.test.skip}"
+     * @readonly
+     */
+    private boolean skip;
+    
+    @Override
+    protected String getScope() {
+        return Artifact.SCOPE_TEST;
+    }
+
+    @Override
+    protected File getOutputDirectory() {
+        return outputDirectory;
+    }
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        if (skip) {
+            getLog().info("Tests are skipped");
+        } else {
+            super.execute();
+        }
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: axis/axis2/java/core/trunk/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/pom.xml?rev=981095&r1=981094&r2=981095&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/pom.xml (original)
+++ axis/axis2/java/core/trunk/pom.xml Sat Jul 31 22:06:30 2010
@@ -60,6 +60,7 @@
         <module>modules/tool/axis2-idea-plugin</module>
         <module>modules/tool/axis2-java2wsdl-maven-plugin</module>
         <module>modules/tool/axis2-mar-maven-plugin</module>
+        <module>modules/tool/axis2-repo-maven-plugin</module>
         <module>modules/tool/axis2-wsdl2code-maven-plugin</module>
         <module>modules/webapp</module>
         <module>modules/xmlbeans</module>