You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Henri Gomez <he...@gmail.com> on 2008/11/04 21:16:37 UTC

custom packaging, how to get jars from wars

Hi to all,

I'm writing a custom packager to help my IT create ZIP archives from a
sum of jars/wars.

I could get the jars/wars but can't figure how to get the jars
required by wars (we didn't put them in WEB-INF/lib since we should
share them).

here is my actual code, how could I get jar dependencies from the WAR artifact ?

Thanks

---

   /**
    * Copy runtime wars
    * @throws MojoExecutionException
    */
   protected int copyWars() throws MojoExecutionException {

		int count = 0;

		try {
			Set artifacts = project.getArtifacts();
			for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
				Artifact artifact = (Artifact) iter.next();
				ScopeArtifactFilter filter = new ScopeArtifactFilter(
						Artifact.SCOPE_RUNTIME);
				if (!artifact.isOptional() && filter.include(artifact)
						&& "war".equals(artifact.getType())) {
					FileUtils.copyFileToDirectory(artifact.getFile(),
							warDirectory);

					count++;
				}
			}
		} catch (IOException e) {
			throw new MojoExecutionException("Error copying wars", e);
		}

		return (count);
	}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org