Revision: 6173
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6173&view=rev
Author: manningr
Date: 2011-03-06 00:43:28 +0000 (Sun, 06 Mar 2011)
Log Message:
-----------
New plugin that extends the maven-dependency-plugin to provide fine-grained control over artifacts that are to be copied.
Modified Paths:
--------------
trunk/maven-plugin-workspace/pom.xml
Added Paths:
-----------
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/pom.xml
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/net/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/net/sf/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/net/sf/squirrel_sql/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/net/sf/squirrel_sql/CopySquirrelDependenciesMojo.java
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/resources/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/test/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/test/java/
trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/test/resources/
Modified: trunk/maven-plugin-workspace/pom.xml
===================================================================
--- trunk/maven-plugin-workspace/pom.xml 2011-03-05 19:48:42 UTC (rev 6172)
+++ trunk/maven-plugin-workspace/pom.xml 2011-03-06 00:43:28 UTC (rev 6173)
@@ -54,6 +54,7 @@
<url>https://www.squirrel-sql.org/hudson/</url>
</ciManagement>
<modules>
+ <module>squirrelsql-dependency-plugin</module>
<module>squirrelsql-update-site-plugin</module>
<module>squirrelsql-version-plugin</module>
</modules>
Property changes on: trunk/maven-plugin-workspace/squirrelsql-dependency-plugin
___________________________________________________________________
Added: svn:ignore
+ target
.project
.classpath
.settings
Added: trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/pom.xml
===================================================================
--- trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/pom.xml (rev 0)
+++ trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/pom.xml 2011-03-06 00:43:28 UTC (rev 6173)
@@ -0,0 +1,88 @@
+<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>maven-plugin-workspace</artifactId>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <version>1.0.7-SNAPSHOT</version>
+ </parent>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>squirrelsql-dependency-plugin</artifactId>
+ <version>1.0.7-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>SQuirreL SQL Dependency Plugin</name>
+ <description>This maven plugin extends the maven dependency plugin's CopyDependenciesMojo to provide more
+ precise control over which artifacts are included in the copy operation. Specifically, in addition to the
+ normal configuration provided by the CopyDependenciesMojo, it accepts a configuration of includedArtifacts
+ which is a list containing a single entry for each includedArtifact where the value is the groupId and
+ the artifactId joined by a colon (":")</description>
+ <inceptionYear>2001</inceptionYear>
+ <developers>
+ <developer>
+ <name>Gerd Wagner</name>
+ <roles>
+ <role>Administrator</role>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <name>Rob Manning</name>
+ <roles>
+ <role>Developer</role>
+ <role>Release Manager</role>
+ </roles>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>GNU Lesser</name>
+ <url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <url>http://www.squirrelsql.org/</url>
+ <scm>
+ <connection>scm:svn:http://squirrel-sql.svn.sourceforge.net/svnroot/squirrel-sql/trunk/maven-plugin-workspace/squirrelsql-version-plugin</connection>
+ <developerConnection>scm:svn:https://squirrel-sql.svn.sourceforge.net/svnroot/squirrel-sql/trunk/maven-plugin-workspace/squirrelsql-version-plugin</developerConnection>
+ <url>http://squirrel-sql.svn.sourceforge.net/viewvc/squirrel-sql/trunk/maven-plugin-workspace/squirrelsql-version-plugin</url>
+ </scm>
+ <issueManagement>
+ <system>SourceForge Tracker</system>
+ <url>http://sourceforge.net/tracker/?group_id=28383%26atid=393414</url>
+ </issueManagement>
+ <ciManagement>
+ <system>Hudson</system>
+ <url>https://www.squirrel-sql.org/hudson/</url>
+ </ciManagement>
+ <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</groupId>
+ <artifactId>maven-settings</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.2</version>
+ <type>maven-plugin</type>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Added: trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/net/sf/squirrel_sql/CopySquirrelDependenciesMojo.java
===================================================================
--- trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/net/sf/squirrel_sql/CopySquirrelDependenciesMojo.java (rev 0)
+++ trunk/maven-plugin-workspace/squirrelsql-dependency-plugin/src/main/java/net/sf/squirrel_sql/CopySquirrelDependenciesMojo.java 2011-03-06 00:43:28 UTC (rev 6173)
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2011 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package net.sf.squirrel_sql;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.CopyDependenciesMojo;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * This mojo extends the functionality of the copy dependencies mojo to all for specifying included artifacts
+ * using both the groupId and artifactId for finer precision.
+ *
+ * @goal copy-dependencies
+ * @requiresDependencyResolution test
+ * @threadSafe
+ */
+public class CopySquirrelDependenciesMojo extends CopyDependenciesMojo
+{
+ private org.apache.maven.plugin.logging.Log log = getLog();
+
+ /**
+ * POM
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ * @required
+ */
+ protected MavenProject project;
+
+ public void setProject(MavenProject project) {
+ super.project = project;
+ this.project = project;
+ }
+
+ /**
+ * @parameter property="stripVersion"
+ */
+ private boolean stripVersion;
+
+ public void setStripVersion(boolean stripVersion) {
+ super.stripVersion = stripVersion;
+ this.stripVersion = stripVersion;
+ }
+
+ /**
+ * @parameter property="outputDirectory"
+ */
+ private File outputDirectory;
+
+ public void setOutputDirectory(File outputDirectory) {
+ super.outputDirectory = outputDirectory;
+ this.outputDirectory = outputDirectory;
+ }
+
+ /**
+ * @parameter property="excludeGroupIds"
+ */
+ private String excludeGroupIds;
+
+ public void setExcludeGroupIds(String excludeGroupIds) {
+ super.excludeGroupIds = excludeGroupIds;
+ this.excludeGroupIds = excludeGroupIds;
+ }
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @component
+ */
+ protected org.apache.maven.artifact.factory.ArtifactFactory factory;
+
+ public void setFactory(org.apache.maven.artifact.factory.ArtifactFactory factory) {
+ this.factory = factory;
+ super.factory = factory;
+ }
+
+
+ /**
+ * This is expected to be a list of artifacts (/groupId/:/artifactId/) and should look like the following:
+ *
+ * <pre>
+ * <includedArtifacts>
+ * <includedArtifact>net.sf.squirrel-sql:fw</includedArtifact>
+ * <includedArtifact>log4j:log4j</includedArtifact>
+ * ...
+ * </includedArtifacts>
+ * </pre>
+ *
+ * @parameter
+ */
+ @SuppressWarnings("unchecked")
+ private List includedArtifacts;
+
+ private Set<String> artifactSet = new HashSet<String>();
+
+ @SuppressWarnings("unchecked")
+ public void setIncludedArtifacts(List includedArtifacts) {
+ this.includedArtifacts = includedArtifacts;
+
+ for (Object item : this.includedArtifacts) {
+ String itemStr = (String)item;
+ artifactSet.add(itemStr.toLowerCase());
+ }
+ }
+
+ /**
+ * Main entry into mojo. Gets the list of dependencies and iterates through
+ * calling copyArtifact.
+ *
+ * @throws MojoExecutionException
+ * with a message if an error occurs.
+ *
+ * @see #getDependencies
+ * @see #copyArtifact(Artifact, boolean)
+ */
+ @Override
+ public void execute()
+ throws MojoExecutionException
+ {
+ super.execute();
+ }
+ /**
+ * @see org.apache.maven.plugin.dependency.CopyDependenciesMojo#copyArtifact(org.apache.maven.artifact.Artifact, boolean)
+ */
+ @Override
+ protected void copyArtifact(Artifact arg0, boolean arg1, boolean arg2) throws MojoExecutionException
+ {
+ String key = arg0.getGroupId().trim().toLowerCase() + ":" + arg0.getArtifactId().trim().toLowerCase();
+ if (artifactSet.contains(key)) {
+ super.copyArtifact(arg0, arg1, arg2);
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|