You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ol...@apache.org on 2011/10/17 16:03:23 UTC
svn commit: r1185178 -
/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Author: olamy
Date: Mon Oct 17 14:03:22 2011
New Revision: 1185178
URL: http://svn.apache.org/viewvc?rev=1185178&view=rev
Log:
[MTOMCAT-102] implements extraDependencies to be able to jdbc driver mail etc.. to the root classloader (ie including in the standalone jar)
Modified:
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java?rev=1185178&r1=1185177&r2=1185178&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java (original)
+++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java Mon Oct 17 14:03:22 2011
@@ -88,11 +88,6 @@ public abstract class AbstractExecWarMoj
private List<Artifact> pluginArtifacts;
/**
- * @parameter
- */
- private List<Dependency> extraDependencies;
-
- /**
* @parameter default-value="${project.build.directory}"
*/
private File buildDirectory;
@@ -208,6 +203,13 @@ public abstract class AbstractExecWarMoj
* @required
*/
private String accessLogValveFormat;
+
+ /**
+ * list of extra dependencies to add in the standalone tomcat jar: your jdbc driver, mail.jar etc..
+ * <b>Those dependencies will be in root classloader.</b>
+ * @parameter
+ */
+ private List<Dependency> extraDependencies;
public void execute()
throws MojoExecutionException, MojoFailureException
@@ -357,6 +359,31 @@ public abstract class AbstractExecWarMoj
}
}
}
+
+ // add extra dependencies
+ if ( extraDependencies != null && !extraDependencies.isEmpty() )
+ {
+ for ( Dependency dependency : extraDependencies )
+ {
+ // String groupId, String artifactId, String version, String scope, String type
+ Artifact artifact =
+ artifactFactory.createArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getScope(), dependency.getType() );
+
+ artifactResolver.resolve( artifact, this.remoteRepos , this.local );
+ JarFile jarFile = new JarFile( artifact.getFile() );
+ Enumeration<JarEntry> jarEntries = jarFile.entries();
+ while ( jarEntries.hasMoreElements() )
+ {
+ JarEntry jarEntry = jarEntries.nextElement();
+ InputStream jarEntryIs = jarFile.getInputStream(jarEntry);
+
+ os.putArchiveEntry( new JarArchiveEntry( jarEntry.getName() ) );
+ IOUtils.copy( jarEntryIs, os );
+ os.closeArchiveEntry();
+ }
+ }
+ }
+
Manifest manifest = new Manifest( );
Manifest.Attribute mainClassAtt = new Manifest.Attribute( );
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org