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 2013/11/06 04:21:36 UTC
svn commit: r1539226 -
/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Author: olamy
Date: Wed Nov 6 03:21:36 2013
New Revision: 1539226
URL: http://svn.apache.org/r1539226
Log:
[MTOMCAT-196] Add the possiblilty to search warRunDepencies and extraDependcies throug the dependencyManagement
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=1539226&r1=1539225&r2=1539226&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 Wed Nov 6 03:21:36 2013
@@ -389,11 +389,23 @@ public abstract class AbstractExecWarMoj
{
for ( Dependency dependency : extraDependencies )
{
+ String version = dependency.getVersion();
+ if ( StringUtils.isEmpty( version ) )
+ {
+ version = findArtifactVersion( dependency );
+ }
+
+ if ( StringUtils.isEmpty( version ) )
+ {
+ throw new MojoExecutionException(
+ "Dependency '" + dependency.getGroupId() + "':'" + dependency.getArtifactId()
+ + "' does not have version specified" );
+ }
+
// String groupId, String artifactId, String version, String scope, String type
Artifact artifact =
- artifactFactory.createArtifact( dependency.getGroupId(), dependency.getArtifactId(),
- dependency.getVersion(), dependency.getScope(),
- dependency.getType() );
+ artifactFactory.createArtifact( dependency.getGroupId(), dependency.getArtifactId(), version,
+ dependency.getScope(), dependency.getType() );
artifactResolver.resolve( artifact, this.remoteRepos, this.local );
JarFile jarFile = new JarFile( artifact.getFile() );
@@ -482,6 +494,35 @@ public abstract class AbstractExecWarMoj
}
}
+ protected String findArtifactVersion( Dependency dependency )
+ {
+ // search in project.dependencies
+ for ( Dependency projectDependency : (List<Dependency>) this.project.getDependencies() )
+ {
+ if ( sameDependencyWithoutVersion( dependency, projectDependency ) )
+ {
+ return projectDependency.getVersion();
+ }
+ }
+
+ // search in project.dependencies
+ for ( Dependency projectDependency : (List<Dependency>) this.project.getDependencyManagement().getDependencies() )
+ {
+ if ( sameDependencyWithoutVersion( dependency, projectDependency ) )
+ {
+ return projectDependency.getVersion();
+ }
+ }
+
+ return null;
+ }
+
+ protected boolean sameDependencyWithoutVersion( Dependency that, Dependency dependency )
+ {
+ return StringUtils.equals( that.getGroupId(), dependency.getGroupId() ) && StringUtils.equals(
+ that.getArtifactId(), dependency.getArtifactId() );
+ }
+
protected void copyDirectoryContentIntoArchive( File sourceFolder, String destinationPath,
ArchiveOutputStream archiveOutputStream )
throws IOException
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org