You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/12/05 16:40:18 UTC
svn commit: r601366 -
/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java
Author: felixk
Date: Wed Dec 5 07:40:18 2007
New Revision: 601366
URL: http://svn.apache.org/viewvc?rev=601366&view=rev
Log:
New goal
Added:
directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java (with props)
Added: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java?rev=601366&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java (added)
+++ directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java Wed Dec 5 07:40:18 2007
@@ -0,0 +1,119 @@
+/*
+ * 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.directory.studio.maven.plugins;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Prepares for jar: Copy artifacts nonscoped "provided" to
+ * ${project.build.outputDirectory}/libraryPath
+ *
+ * @goal prepare-jar-package
+ * @description Prepares for jar: Copy artifacts nonscoped "provided" to
+ * ${project.build.outputDirectory}/libraryPath
+ * @requiresProject
+ * @requiresDependencyResolution runtime
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Id$
+ */
+public class StudioPrepareJarPackageMojo extends AbstractStudioMojo {
+
+ /**
+ * POM
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ * @required
+ */
+ protected MavenProject project;
+
+ /**
+ * Directory containing the classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @readonly
+ * @required
+ */
+ private File classesDirectory;
+
+ public void execute() throws MojoExecutionException {
+ if (!skip) {
+ try {
+ // Create list of used artifacts
+ final List<Artifact> artifactList = createArtifactList();
+
+ // copy Artifacts
+ copyArtifacts(artifactList);
+
+ } catch (Exception e) {
+ getLog().error(e);
+ }
+ }
+ }
+
+ /**
+ * Return a list of artifacts nonscoped "provided"
+ *
+ * @return
+ */
+ private List<Artifact> createArtifactList() {
+ List<Artifact> list = new ArrayList<Artifact>();
+ for (Iterator<Artifact> artifactItem = project.getArtifacts().iterator(); artifactItem.hasNext();) {
+ Artifact artifact = (Artifact) artifactItem.next();
+ if (!artifact.getScope().equalsIgnoreCase("provided")) {
+ list.add(artifact);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Copy artifacts to ${basedir}/lib
+ *
+ * @param list
+ * @throws IOException
+ */
+ private void copyArtifacts(final List<Artifact> list) throws IOException {
+ // Only proceed when we have artifacts to process
+ if (!list.isEmpty()) {
+ final File copyDir = new File(classesDirectory, libraryPath);
+
+ if (!copyDir.exists())
+ copyDir.mkdirs();
+
+ for (Artifact artifact : list) {
+ final File destFile = new File(copyDir, artifact.getFile().getName());
+ FileUtils.copyFile(artifact.getFile(), destFile);
+ getLog().info("Copying " + artifact.getFile() + " to " + destFile);
+ }
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioPrepareJarPackageMojo.java
------------------------------------------------------------------------------
svn:keywords = Id