Author: veithen
Date: Tue Dec 19 20:12:05 2017
New Revision: 1818717

URL: http://svn.apache.org/viewvc?rev=1818717&view=rev
Log:
Use a smarter way to deploy an exploded AAR from the service description 
produced by the code generator.

Added:
    
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/Parameter.java
   (with props)
    
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/ServiceDescription.java
   (with props)
Removed:
    axis/axis2/java/core/trunk/modules/adb-tests/src/test/xslt/
Modified:
    axis/axis2/java/core/trunk/modules/adb-tests/pom.xml
    
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java

Modified: axis/axis2/java/core/trunk/modules/adb-tests/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/pom.xml?rev=1818717&r1=1818716&r2=1818717&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-tests/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/adb-tests/pom.xml Tue Dec 19 20:12:05 
2017
@@ -366,42 +366,68 @@
                 </executions>
             </plugin>
             <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <version>1.0.1</version>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>axis2-repo-maven-plugin</artifactId>
+                <version>${project.version}</version>
                 <executions>
                     <execution>
-                        <phase>generate-test-resources</phase>
+                        <id>repo-axis2-5741</id>
                         <goals>
-                            <goal>transform</goal>
+                            <goal>create-test-repository</goal>
                         </goals>
                         <configuration>
-                            <transformationSets>
-                                <transformationSet>
-                                    
<dir>${project.build.directory}/wsdl2code/AXIS2-5741/resources</dir>
-                                    <includes>
-                                        <include>services.xml</include>
-                                    </includes>
-                                    
<stylesheet>src/test/xslt/AXIS2-5741.xsl</stylesheet>
-                                    
<outputDir>${project.build.directory}/repo/AXIS2-5741/services/FiverxLinkService/META-INF</outputDir>
-                                </transformationSet>
-                                <transformationSet>
-                                    
<dir>${project.build.directory}/wsdl2code/AXIS2-5749/resources</dir>
-                                    <includes>
-                                        <include>services.xml</include>
-                                    </includes>
-                                    
<stylesheet>src/test/xslt/AXIS2-5749.xsl</stylesheet>
-                                    
<outputDir>${project.build.directory}/repo/AXIS2-5749/services/ColorService/META-INF</outputDir>
-                                </transformationSet>
-                                <transformationSet>
-                                    
<dir>${project.build.directory}/wsdl2code/AXIS2-5809/resources</dir>
-                                    <includes>
-                                        <include>services.xml</include>
-                                    </includes>
-                                    
<stylesheet>src/test/xslt/AXIS2-5809.xsl</stylesheet>
-                                    
<outputDir>${project.build.directory}/repo/AXIS2-5809/services/EchoService/META-INF</outputDir>
-                                </transformationSet>
-                            </transformationSets>
+                            
<outputDirectory>${project.build.directory}/repo/AXIS2-5741</outputDirectory>
+                            <serviceDescriptions>
+                                <serviceDescription>
+                                    
<directory>${project.build.directory}/wsdl2code/AXIS2-5741/resources</directory>
+                                    <parameters>
+                                        <parameter>
+                                            <name>ServiceClass</name>
+                                            
<value>org.apache.axis2.databinding.axis2_5741.service.FiverxLinkServiceImpl</value>
+                                        </parameter>
+                                    </parameters>
+                                </serviceDescription>
+                            </serviceDescriptions>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>repo-axis2-5749</id>
+                        <goals>
+                            <goal>create-test-repository</goal>
+                        </goals>
+                        <configuration>
+                            
<outputDirectory>${project.build.directory}/repo/AXIS2-5749</outputDirectory>
+                            <serviceDescriptions>
+                                <serviceDescription>
+                                    
<directory>${project.build.directory}/wsdl2code/AXIS2-5749/resources</directory>
+                                    <parameters>
+                                        <parameter>
+                                            <name>ServiceClass</name>
+                                            
<value>org.apache.axis2.databinding.axis2_5749.service.ColorServiceImpl</value>
+                                        </parameter>
+                                    </parameters>
+                                </serviceDescription>
+                            </serviceDescriptions>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>repo-axis2-5809</id>
+                        <goals>
+                            <goal>create-test-repository</goal>
+                        </goals>
+                        <configuration>
+                            
<outputDirectory>${project.build.directory}/repo/AXIS2-5809</outputDirectory>
+                            <serviceDescriptions>
+                                <serviceDescription>
+                                    
<directory>${project.build.directory}/wsdl2code/AXIS2-5809/resources</directory>
+                                    <parameters>
+                                        <parameter>
+                                            <name>ServiceClass</name>
+                                            
<value>org.apache.axis2.databinding.axis2_5809.EchoServiceImpl</value>
+                                        </parameter>
+                                    </parameters>
+                                </serviceDescription>
+                            </serviceDescriptions>
                         </configuration>
                     </execution>
                 </executions>

Modified: 
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=1818717&r1=1818716&r2=1818717&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java
 Tue Dec 19 20:12:05 2017
@@ -20,6 +20,7 @@
 package org.apache.axis2.maven2.repo;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -192,6 +193,13 @@ public abstract class AbstractCreateRepo
      */
     private JAXWSService[] jaxwsServices;
     
+    /**
+     * A list of service descriptions that should be processed to build 
exploded AARs.
+     * 
+     * @parameter
+     */
+    private ServiceDescription[] serviceDescriptions;
+    
     protected abstract String getScope();
     
     protected abstract File getInputDirectory();
@@ -297,6 +305,74 @@ public abstract class AbstractCreateRepo
                 }
             }
         }
+        if (serviceDescriptions != null) {
+            File parentDirectory = new File(outputDirectory, 
servicesDirectory);
+            for (ServiceDescription serviceDescription : serviceDescriptions) {
+                File servicesFile = new 
File(serviceDescription.getDirectory(), "services.xml");
+                File metaInfDirectory;
+                try {
+                    InputStream in = new FileInputStream(servicesFile);
+                    try {
+                        OMDocument doc = 
OMXMLBuilderFactory.createOMBuilder(in).getDocument();
+                        OMElement serviceElement;
+                        {
+                            Iterator<OMElement> it = 
doc.getOMDocumentElement().getChildrenWithLocalName("service");
+                            if (!it.hasNext()) {
+                                throw new MojoFailureException("No service 
found in " + servicesFile);
+                            }
+                            serviceElement = it.next();
+                            if (it.hasNext()) {
+                                throw new MojoFailureException(servicesFile + 
" contains more than one service");
+                            }
+                        }
+                        String serviceName = 
serviceElement.getAttributeValue(new QName("name"));
+                        log.info("Building service " + serviceName);
+                        metaInfDirectory = new File(new File(parentDirectory, 
serviceName), "META-INF");
+                        metaInfDirectory.mkdirs();
+                        for (Parameter parameter : 
serviceDescription.getParameters()) {
+                            OMElement parameterElement = null;
+                            for (Iterator<OMElement> it = 
serviceElement.getChildrenWithLocalName("parameter"); it.hasNext(); ) {
+                                OMElement candidate = it.next();
+                                if (candidate.getAttributeValue(new 
QName("name")).equals(parameter.getName())) {
+                                    parameterElement = candidate;
+                                    break;
+                                }
+                            }
+                            if (parameterElement == null) {
+                                parameterElement = 
doc.getOMFactory().createOMElement("parameter", null, serviceElement);
+                                parameterElement.addAttribute("name", 
parameter.getName(), null);
+                            }
+                            parameterElement.setText(parameter.getValue());
+                        }
+                        FileOutputStream out = new FileOutputStream(new 
File(metaInfDirectory, "services.xml"));
+                        try {
+                            doc.serialize(out);
+                        } finally {
+                            out.close();
+                        }
+                    } finally {
+                        in.close();
+                    }
+                    DirectoryScanner ds = new DirectoryScanner();
+                    ds.setBasedir(serviceDescription.getDirectory());
+                    ds.setExcludes(new String[] { "services.xml" });
+                    ds.scan();
+                    for (String relativePath : ds.getIncludedFiles()) {
+                        try {
+                            FileUtils.copyFile(
+                                    new 
File(serviceDescription.getDirectory(), relativePath),
+                                    new File(metaInfDirectory, relativePath));
+                        } catch (IOException ex) {
+                            throw new MojoExecutionException("Failed to copy " 
+ relativePath, ex);
+                        }
+                    }
+                } catch (IOException ex) {
+                    throw new MojoExecutionException(ex.getMessage(), ex);
+                } catch (XMLStreamException ex) {
+                    throw new MojoExecutionException(ex.getMessage(), ex);
+                }
+            }
+        }
         if (generatedAxis2xml != null || axis2xml != null) {
             File targetDirectory = configurationDirectory == null
                     ? outputDirectory : new File(outputDirectory, 
configurationDirectory);

Added: 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/Parameter.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/Parameter.java?rev=1818717&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/Parameter.java
 (added)
+++ 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/Parameter.java
 Tue Dec 19 20:12:05 2017
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+public class Parameter {
+    private String name;
+    private String value;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

Propchange: 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/Parameter.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/ServiceDescription.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/ServiceDescription.java?rev=1818717&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/ServiceDescription.java
 (added)
+++ 
axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/ServiceDescription.java
 Tue Dec 19 20:12:05 2017
@@ -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.axis2.maven2.repo;
+
+import java.io.File;
+
+public class ServiceDescription {
+    private File directory;
+    private Parameter[] parameters;
+
+    public File getDirectory() {
+        return directory;
+    }
+
+    public void setDirectory(File directory) {
+        this.directory = directory;
+    }
+
+    public Parameter[] getParameters() {
+        return parameters;
+    }
+
+    public void setParameters(Parameter[] parameters) {
+        this.parameters = parameters;
+    }
+}

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


Reply via email to