start importing jpox maven plugins and fix build with snapshot repo

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-components/trunk@1446707 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jpox-modello-maven-plugin/pom.xml b/jpox-modello-maven-plugin/pom.xml
new file mode 100644
index 0000000..b39867a
--- /dev/null
+++ b/jpox-modello-maven-plugin/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<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/xsd/maven-4.0.0.xsd">

+  <modelVersion>4.0.0</modelVersion>

+  <parent>

+    <artifactId>modello-plugins</artifactId>

+    <groupId>org.apache.archiva.redback.components.modello</groupId>

+    <version>1.0-SNAPSHOT</version>

+  </parent>

+

+  <artifactId>jpox-modello-maven-plugin</artifactId>

+  <packaging>maven-plugin</packaging>

+

+  <name>jpox-modello-maven-plugin Maven Plugin</name>

+

+

+  <dependencies>

+    <dependency>

+      <groupId>org.apache.maven</groupId>

+      <artifactId>maven-plugin-api</artifactId>

+      <version>2.0</version>

+    </dependency>

+    <dependency>

+      <groupId>org.apache.maven.plugin-tools</groupId>

+      <artifactId>maven-plugin-annotations</artifactId>

+      <version>3.2</version>

+      <scope>provided</scope>

+    </dependency>

+    <dependency>

+      <groupId>org.codehaus.modello</groupId>

+      <artifactId>modello-maven-plugin</artifactId>

+      <version>${modelloVersion}</version>

+    </dependency>

+  </dependencies>

+

+  <build>

+    <plugins>

+      <plugin>

+        <groupId>org.apache.maven.plugins</groupId>

+        <artifactId>maven-plugin-plugin</artifactId>

+        <version>3.2</version>

+        <configuration>

+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>

+        </configuration>

+        <executions>

+          <execution>

+            <id>mojo-descriptor</id>

+            <goals>

+              <goal>descriptor</goal>

+            </goals>

+          </execution>

+          <execution>

+            <id>help-goal</id>

+            <goals>

+              <goal>helpmojo</goal>

+            </goals>

+          </execution>

+        </executions>

+      </plugin>

+    </plugins>

+  </build>

+  <profiles>

+    <profile>

+      <id>run-its</id>

+      <build>

+

+        <plugins>

+          <plugin>

+            <groupId>org.apache.maven.plugins</groupId>

+            <artifactId>maven-invoker-plugin</artifactId>

+            <version>1.7</version>

+            <configuration>

+              <debug>true</debug>

+              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>

+              <pomIncludes>

+                <pomInclude>*/pom.xml</pomInclude>

+              </pomIncludes>

+              <postBuildHookScript>verify</postBuildHookScript>

+              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>

+              <settingsFile>src/it/settings.xml</settingsFile>

+              <goals>

+                <goal>clean</goal>

+                <goal>test-compile</goal>

+              </goals>

+            </configuration>

+            <executions>

+              <execution>

+                <id>integration-test</id>

+                <goals>

+                  <goal>install</goal>

+                  <goal>integration-test</goal>

+                  <goal>verify</goal>

+                </goals>

+              </execution>

+            </executions>

+          </plugin>

+        </plugins>

+

+      </build>

+    </profile>

+  </profiles>

+</project>

diff --git a/jpox-modello-maven-plugin/src/it/settings.xml b/jpox-modello-maven-plugin/src/it/settings.xml
new file mode 100644
index 0000000..000e726
--- /dev/null
+++ b/jpox-modello-maven-plugin/src/it/settings.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<settings>
+  <profiles>
+    <profile>
+      <id>it-repo</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+</settings>
diff --git a/jpox-modello-maven-plugin/src/it/simple-it/pom.xml b/jpox-modello-maven-plugin/src/it/simple-it/pom.xml
new file mode 100644
index 0000000..aefe557
--- /dev/null
+++ b/jpox-modello-maven-plugin/src/it/simple-it/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.archiva.redback.components.modello.it</groupId>
+  <artifactId>simple-it</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <description>A simple IT verifying the basic use case.</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>touch</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>touch</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/jpox-modello-maven-plugin/src/it/simple-it/verify.groovy b/jpox-modello-maven-plugin/src/it/simple-it/verify.groovy
new file mode 100644
index 0000000..7b307c7
--- /dev/null
+++ b/jpox-modello-maven-plugin/src/it/simple-it/verify.groovy
@@ -0,0 +1,3 @@
+File touchFile = new File( basedir, "target/touch.txt" );
+
+assert touchFile.isFile()
diff --git a/jpox-modello-maven-plugin/src/main/java/org/apache/archiva/redback/components/modello/plugin/jpox/ModelloJPoxJdoMappingMojo.java b/jpox-modello-maven-plugin/src/main/java/org/apache/archiva/redback/components/modello/plugin/jpox/ModelloJPoxJdoMappingMojo.java
new file mode 100644
index 0000000..8f3b3be
--- /dev/null
+++ b/jpox-modello-maven-plugin/src/main/java/org/apache/archiva/redback/components/modello/plugin/jpox/ModelloJPoxJdoMappingMojo.java
@@ -0,0 +1,93 @@
+package org.apache.archiva.redback.components.modello.plugin.jpox;
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.codehaus.modello.ModelloParameterConstants;
+import org.codehaus.modello.maven.AbstractModelloGeneratorMojo;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * Creates a JDO mapping from the Modello model.
+ *
+ * @author Olivier Lamy
+ */
+@Mojo( name = "jpox-jdo-mapping", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
+public class ModelloJPoxJdoMappingMojo
+    extends AbstractModelloGeneratorMojo
+{
+    /**
+     * The output directory of the generated JDO mapping file.
+     * <p/>
+     * Please be aware of the &lt;model jpox.mapping-in-package="true" &gt; attribute present in
+     * the model file itself.
+     */
+    @Parameter( defaultValue = "${basedir}/target/generated-resources/modello", required = true )
+    private File outputDirectory;
+
+    /**
+     * Produce a mapping file suitable for replication. It will have an alternate extension of '.jdorepl' so it is not
+     * picked up by default, and all value-strategy and objectid-class entries are removed from the mapping so that
+     * the original identities can be used.
+     */
+    @Parameter( defaultValue = "false" )
+    private boolean replicationParameters;
+
+    protected String getGeneratorType()
+    {
+        return "jpox-jdo-mapping";
+    }
+
+    protected boolean producesCompilableResult()
+    {
+        return false;
+    }
+
+    protected boolean producesResources()
+    {
+        return true;
+    }
+
+    public File getOutputDirectory()
+    {
+        return outputDirectory;
+    }
+
+    public void setOutputDirectory( File outputDirectory )
+    {
+        this.outputDirectory = outputDirectory;
+    }
+
+    protected void customizeParameters( Properties parameters )
+    {
+        super.customizeParameters( parameters );
+
+        if ( replicationParameters )
+        {
+            parameters.setProperty( ModelloParameterConstants.FILENAME, "package.jdorepl" );
+
+            parameters.setProperty( "JPOX.override.value-strategy", "off" );
+            parameters.setProperty( "JPOX.override.objectid-class", "" );
+        }
+    }
+}
\ No newline at end of file
diff --git a/jpox-modello-maven-plugin/src/main/java/org/apache/archiva/redback/components/modello/plugin/jpox/MyMojo.java b/jpox-modello-maven-plugin/src/main/java/org/apache/archiva/redback/components/modello/plugin/jpox/MyMojo.java
new file mode 100644
index 0000000..d3ebde6
--- /dev/null
+++ b/jpox-modello-maven-plugin/src/main/java/org/apache/archiva/redback/components/modello/plugin/jpox/MyMojo.java
@@ -0,0 +1,67 @@
+package org.apache.archiva.redback.components.modello.plugin.jpox;
+
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * Goal which touches a timestamp file.
+ */
+@Mojo( name = "touch", defaultPhase = LifecyclePhase.PROCESS_SOURCES )
+public class MyMojo
+    extends AbstractMojo
+{
+    /**
+     * Location of the file.
+     */
+    @Parameter( defaultValue = "${project.build.directory}", property = "outputDir", required = true )
+    private File outputDirectory;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        File f = outputDirectory;
+
+        if ( !f.exists() )
+        {
+            f.mkdirs();
+        }
+
+        File touch = new File( f, "touch.txt" );
+
+        FileWriter w = null;
+        try
+        {
+            w = new FileWriter( touch );
+
+            w.write( "touch.txt" );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error creating file " + touch, e );
+        }
+        finally
+        {
+            if ( w != null )
+            {
+                try
+                {
+                    w.close();
+                }
+                catch ( IOException e )
+                {
+                    // ignore
+                }
+            }
+        }
+    }
+}
diff --git a/pom.xml b/pom.xml
index cfe0e8a..6d63330 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,7 @@
     <module>modello-plugin-store</module>
     <module>modello-plugin-jpox</module>
     <module>modello-plugin-redback-registry</module>
+    <module>jpox-modello-maven-plugin</module>
   </modules>
 
   <dependencyManagement>
@@ -92,4 +93,17 @@
     </dependencies>
   </dependencyManagement>
 
-</project>
+  <repositories>
+    <repository>
+      <id>modello.snapshots</id>
+      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+</project>
\ No newline at end of file