Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 5520 invoked from network); 8 Mar 2006 20:39:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Mar 2006 20:39:47 -0000 Received: (qmail 54213 invoked by uid 500); 8 Mar 2006 20:39:46 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 54181 invoked by uid 500); 8 Mar 2006 20:39:46 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 54170 invoked by uid 99); 8 Mar 2006 20:39:46 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Mar 2006 12:39:45 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 08 Mar 2006 12:39:44 -0800 Received: (qmail 5022 invoked by uid 65534); 8 Mar 2006 20:39:24 -0000 Message-ID: <20060308203924.5021.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r384325 - in /geronimo/devtools/eclipse-plugin/trunk: geronimo-emf/pom.xml maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ImportResourcesMojo.java Date: Wed, 08 Mar 2006 20:39:23 -0000 To: scm@geronimo.apache.org From: sppatel@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: sppatel Date: Wed Mar 8 12:39:23 2006 New Revision: 384325 URL: http://svn.apache.org/viewcvs?rev=384325&view=rev Log: import schemas Added: geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ImportResourcesMojo.java Modified: geronimo/devtools/eclipse-plugin/trunk/geronimo-emf/pom.xml Modified: geronimo/devtools/eclipse-plugin/trunk/geronimo-emf/pom.xml URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/geronimo-emf/pom.xml?rev=384325&r1=384324&r2=384325&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/geronimo-emf/pom.xml (original) +++ geronimo/devtools/eclipse-plugin/trunk/geronimo-emf/pom.xml Wed Mar 8 12:39:23 2006 @@ -1,14 +1,36 @@ 4.0.0 - geronimo-emf-common - jar - ${geronimo-emf-common_version} - ${artifactId} - - org.apache.geronimo.devtools - geronimo-eclipse-plugin - 1.0 - + geronimo-emf-common + jar + ${geronimo-emf-common_version} + ${artifactId} + + org.apache.geronimo.devtools + geronimo-eclipse-plugin + 1.0 + + + + + org.apache.geronimo.devtools + maven-geronimodevtools-plugin + + schema + + **/*.xsd + + + + + process-resources + + importresources + + + + + + openejb @@ -23,42 +45,42 @@ geronimo geronimo-security-builder - ${geronimo_runtime_version} + ${geronimo_version} geronimo geronimo-naming-builder - ${geronimo_runtime_version} - + ${geronimo_version} + geronimo geronimo-web-builder - ${geronimo_runtime_version} + ${geronimo_version} geronimo geronimo-j2ee-builder - ${geronimo_runtime_version} + ${geronimo_version} geronimo geronimo-service-builder - ${geronimo_runtime_version} + ${geronimo_version} geronimo geronimo-j2ee-schema - ${geronimo_runtime_version} + ${geronimo_version} geronimo geronimo-connector-builder - ${geronimo_runtime_version} + ${geronimo_version} geronimo geronimo-client-builder - ${geronimo_runtime_version} + ${geronimo_version} Added: geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ImportResourcesMojo.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ImportResourcesMojo.java?rev=384325&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ImportResourcesMojo.java (added) +++ geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ImportResourcesMojo.java Wed Mar 8 12:39:23 2006 @@ -0,0 +1,143 @@ +/** + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed 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.geronimo.eclipse.devtools; + +import java.io.File; +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.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Delete; +import org.apache.tools.ant.taskdefs.Expand; +import org.apache.tools.ant.taskdefs.Move; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.PatternSet; + +/** + * @goal importresources + * @requiresDependencyResolution + */ +public class ImportResourcesMojo extends AbstractMojo { + + /** + * @parameter expression="${project}" + * @required + */ + private MavenProject project; + + /** + * @parameter + * @required + */ + private String targetPath; + + /** + * @parameter expression="true" + */ + private boolean flatten; + + /** + * @parameter + */ + private String[] includes; + + private File importDestination; + private File targetDestination; + + /* + * (non-Javadoc) + * + * @see org.apache.maven.plugin.Mojo#execute() + */ + public void execute() throws MojoExecutionException, MojoFailureException { + + Set dependencies = project.getDependencyArtifacts(); + Iterator i = dependencies.iterator(); + + if (dependencies.size() > 0) { + + while (i.hasNext()) { + Artifact artifact = (Artifact) i.next(); + Expand expandTask = new Expand(); + expandTask.setProject(new Project()); + expandTask.setSrc(artifact.getFile()); + expandTask.setDest(getImportDestination()); + if (includes != null) { + PatternSet set = new PatternSet(); + for (int j = 0; j < includes.length; j++) { + set.setIncludes(includes[j]); + } + expandTask.addPatternset(set); + } + expandTask.execute(); + } + + if (flatten) { + flatten(); + cleanup(); + } + } + } + + private void flatten() { + Move moveTask = new Move(); + moveTask.setProject(new Project()); + moveTask.setTodir(getTargetDestination()); + moveTask.setFlatten(true); + + if (includes != null) { + FileSet fileSet = new FileSet(); + fileSet.setDir(getImportDestination()); + for (int j = 0; j < includes.length; j++) { + fileSet.setIncludes(includes[j]); + } + moveTask.addFileset(fileSet); + } + + moveTask.execute(); + } + + private void cleanup() { + Delete deleteTask = new Delete(); + deleteTask.setProject(new Project()); + deleteTask.setDir(getImportDestination()); + deleteTask.execute(); + } + + private File getImportDestination() { + if (importDestination == null) { + String base = project.getBasedir().getAbsolutePath(); + if (flatten) { + importDestination = new File(base + File.separator + "temp"); + } + importDestination = getTargetDestination(); + } + return importDestination; + } + + private File getTargetDestination() { + if (targetDestination == null) { + String base = project.getBasedir().getAbsolutePath(); + return new File(base + File.separator + targetPath); + } + return targetDestination; + } +}