[jboss-svn-commits] JBL Code SVN: r12887 - in labs/jbossesb/workspace: maven and 16 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 27 03:37:38 EDT 2007
Author: kevin.conner at jboss.com
Date: 2007-06-27 03:37:38 -0400 (Wed, 27 Jun 2007)
New Revision: 12887
Added:
labs/jbossesb/workspace/maven/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/pom.xml
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ESBMojo.java
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ReflectionCompositeMap.java
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/META-INF/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/META-INF/plexus/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/META-INF/plexus/components.xml
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/index.apt
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/usage.apt
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/fml/
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/fml/faq.fml
labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/site.xml
Log:
Added first version of maven esb plugin
Property changes on: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin
___________________________________________________________________
Name: svn:ignore
+ target
.classpath
.project
.settings
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/pom.xml
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/pom.xml (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/pom.xml 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,125 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and individual contributors as indicated
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This 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 software 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 software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jboss-esb-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <packaging>maven-plugin</packaging>
+
+ <name>JBoss ESB Maven plugin</name>
+ <description>JBoss ESB Maven plugin</description>
+ <inceptionYear>2007</inceptionYear>
+ <licenses>
+ <license>
+ <name>The GNU Lesser General Public License, Version 2.1</name>
+ <url>http://www.gnu.org/licenses/lgpl.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <organization>
+ <name>JBoss, a division of Red Hat</name>
+ <url>http://www.jboss.org/</url>
+ </organization>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.labs.jboss.com/labs/jbossesb/workspace/maven/maven-jboss-esb-plugin</connection>
+ <developerConnection>scm:svn:https://svn.labs.jboss.com/labs/jbossesb/workspace/maven/maven-jboss-esb-plugin</developerConnection>
+ <url>http://anonsvn.labs.jboss.com/labs/jbossesb/workspace/maven/maven-jboss-esb-plugin</url>
+ </scm>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://jira.jboss.com/jira/browse/JBESB</url>
+ </issueManagement>
+
+ <prerequisites>
+ <maven>2.0.5</maven>
+ </prerequisites>
+
+ <developers>
+ <developer>
+ <id>kevin</id>
+ <name>Kevin Conner</name>
+ <email>KConner at redhat.com</email>
+ <organization>Red Hat Inc.</organization>
+ <roles>
+ <role>JBoss ESB Project Lead</role>
+ </roles>
+ <timezone>0</timezone>
+ </developer>
+ </developers>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ </extension>
+ </extensions>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <distributionManagement>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Release Repository</name>
+ <url>file://${jboss.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>dav:https://snapshots.jboss.org/maven2/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
Property changes on: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ESBMojo.java
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ESBMojo.java (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ESBMojo.java 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,626 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.maven.plugin ;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo ;
+import org.apache.maven.plugin.MojoExecutionException ;
+import org.apache.maven.plugin.MojoFailureException ;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.InterpolationFilterReader;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Builds a JBoss ESB archive.
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ *
+ * @goal esb
+ * @phase package
+ * @requiresDependencyResolution runtime
+ */
+public class ESBMojo extends AbstractMojo
+{
+ /**
+ * The name of the meta-inf directory.
+ */
+ private static final String META_INF = "META-INF" ;
+ /**
+ * The location of the jboss-esb.xml file.
+ */
+ private static final String JBOSS_ESB_XML = "jboss-esb.xml" ;
+ /**
+ * The location of the deployment.xml file.
+ */
+ private static final String DEPLOYMENT_XML = "deployment.xml" ;
+ /**
+ * The suffix of esb archives.
+ */
+ private static final String ESB_SUFFIX = ".esb" ;
+ /**
+ * The default includes.
+ */
+ private static final String DEFAULT_INCLUDES = "**" ;
+
+ /**
+ * The manifest file for the esb archive.
+ * @parameter
+ */
+ private File manifest ;
+
+ /**
+ * The directory which will contain the ESB archive.
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private File outputDirectory ;
+
+ /**
+ * The name of the ESB archive.
+ * @parameter expression="${project.build.finalName}"
+ * @required
+ */
+ private String finalName ;
+
+ /**
+ * Classifier to add to the generated artifact. If given, the artifact
+ * will be an attachment instead.
+ * @parameter
+ */
+ private String classifier ;
+
+ /**
+ * Whether this is the main artifact being constructed.
+ * @parameter expression="${maven.esb.primaryArtifact}" default-value="true"
+ */
+ private boolean primaryArtifact ;
+
+ /**
+ * Override the jboss-esb.xml file
+ * @parameter expression="${maven.esb.jboss.xml}"
+ */
+ private File jbossEsbXml ;
+
+ /**
+ * Override the deployment xml file
+ * @parameter expression="${maven.esb.deployment.xml}"
+ */
+ private File deploymentXml ;
+
+ /**
+ * The directory which contains the exploded ESB.
+ * @parameter expression="${project.build.directory}/${project.build.finalName}"
+ * @required
+ */
+ private File esbDirectory ;
+
+ /**
+ * Additional resources to copy.
+ * @parameter
+ */
+ private Resource[] resources ;
+
+ /**
+ * The directory which contains generated classes.
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ private File classesDirectory ;
+
+ /**
+ * The filters specified in the pom.
+ * @parameter expression="${project.build.filters}"
+ * @readonly
+ */
+ private List filters;
+
+ /**
+ * The maven project.
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project ;
+
+ /**
+ * The JAR archiver.
+ * @component role="org.codehaus.plexus.archiver.Archiver" roleHint="jar"
+ * @required
+ * @readonly
+ */
+ private JarArchiver jarArchiver ;
+
+ /**
+ * The archive configuration to use.
+ * @parameter
+ */
+ private MavenArchiveConfiguration archiveConfiguration = new MavenArchiveConfiguration() ;
+
+ /**
+ * The project helper.
+ * @component
+ */
+ private MavenProjectHelper projectHelper ;
+
+ /**
+ * Execute the mojo.
+ */
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ final File esbFile = calculateEsbFile(outputDirectory, finalName, classifier) ;
+
+ getLog().info("Creating esb archive " + esbFile.getAbsolutePath()) ;
+
+ try
+ {
+ buildESB(project, esbDirectory) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new MojoExecutionException("Failed to construct esb structure", ioe) ;
+ }
+
+ final MavenArchiver archiver = new MavenArchiver() ;
+ archiver.setArchiver(jarArchiver) ;
+ archiver.setOutputFile(esbFile) ;
+ archiver.setOutputFile(esbFile) ;
+
+ try
+ {
+ jarArchiver.addDirectory(esbDirectory) ;
+ }
+ catch (final ArchiverException ae)
+ {
+ throw new MojoExecutionException("Could not add esb output directory: " + esbDirectory.getAbsolutePath(), ae) ;
+ }
+
+ if (manifest != null)
+ {
+ try
+ {
+ jarArchiver.setManifest(manifest) ;
+ }
+ catch (final ArchiverException ae)
+ {
+ throw new MojoExecutionException("Could not register manifest", ae) ;
+ }
+ }
+
+ try
+ {
+ archiver.createArchive(project, archiveConfiguration) ;
+ }
+ catch (final ManifestException me)
+ {
+ throw new MojoExecutionException("Failed to create archive", me) ;
+ }
+ catch (final DependencyResolutionRequiredException drre)
+ {
+ throw new MojoExecutionException("Failed to create archive", drre) ;
+ }
+ catch (final ArchiverException ae)
+ {
+ throw new MojoExecutionException("Failed to create archive", ae) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new MojoExecutionException("Failed to create archive", ioe) ;
+ }
+
+ if (classifier != null)
+ {
+ projectHelper.attachArtifact(project, "esb", classifier, esbFile) ;
+ }
+ else if (primaryArtifact)
+ {
+ final Artifact artifact = project.getArtifact() ;
+ artifact.setFile(esbFile) ;
+ }
+ }
+
+ /**
+ * Calculate the name of the esb archive file.
+ * @param outputDirectory The output directory.
+ * @param finalName The final name of the artifact.
+ * @param classifier The classifier of the artifact.
+ * @return The esb archive file.
+ */
+ private File calculateEsbFile(final File outputDirectory, final String finalName, final String classifier)
+ {
+ final String basename ;
+ if (StringUtils.isEmpty(classifier))
+ {
+ basename = finalName ;
+ }
+ else
+ {
+ basename = finalName + '-' + classifier ;
+ }
+ return new File(outputDirectory, basename + ESB_SUFFIX) ;
+ }
+
+ /**
+ * Build the explodes esb hierarchy.
+ * @param project The current project.
+ * @param esbDirectory The target directory.
+ *
+ * @throws IOException for IO errors.
+ * @throws MojoExecutionException For plugin failures.
+ * @throws MojoFailureException For unexpected plugin failures.
+ */
+ private void buildESB(final MavenProject project, final File esbDirectory)
+ throws IOException, MojoFailureException, MojoExecutionException
+ {
+ getLog().info("BUilding ESB artifact " + project.getArtifactId() + " in " + esbDirectory) ;
+
+ final File metainfDir = new File(esbDirectory, META_INF) ;
+ final File esbFile = new File(metainfDir, JBOSS_ESB_XML) ;
+
+ copyDirectory(classesDirectory, esbDirectory) ;
+
+ final int numResources = (resources == null ? 0 : resources.length) ;
+ if (numResources > 0)
+ {
+ final Map filterProperties = getFilterProperties(project) ;
+ for(int count = 0 ; count < numResources ; count++)
+ {
+ copyResource(resources[count], esbDirectory, filterProperties) ;
+ }
+ }
+
+ if (jbossEsbXml != null)
+ {
+ copyFile(jbossEsbXml, esbFile) ;
+ }
+ if (deploymentXml != null)
+ {
+ copyFile(deploymentXml, new File(metainfDir, DEPLOYMENT_XML)) ;
+ }
+
+ // check for dependent libraries
+ final Set artifacts = project.getArtifacts() ;
+ if (artifacts != null)
+ {
+ final Set includedArtifacts = new HashSet() ;
+ final ScopeArtifactFilter scopeArtifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME) ;
+
+ final Iterator artifactIter = artifacts.iterator() ;
+ while(artifactIter.hasNext())
+ {
+ final Artifact artifact = (Artifact)artifactIter.next() ;
+ if (scopeArtifactFilter.include(artifact) && !artifact.isOptional())
+ {
+ String name = getArtifactName(artifact) ;
+
+ if (!includedArtifacts.add(name))
+ {
+ name = artifact.getGroupId() + "-" + name ;
+ getLog().debug("Duplicate artifact discovered, using full name: " + name) ;
+ }
+
+ try
+ {
+ copyFile(artifact.getFile(), new File(esbDirectory, name)) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new MojoExecutionException("Failed to copy artifact", ioe) ;
+ }
+ }
+ }
+ }
+
+ if (!esbFile.exists())
+ {
+ throw new MojoFailureException("ESB archive does not contain the jboss-esb.xml file") ;
+ }
+ }
+
+ /**
+ * Copy a directory.
+ * @param from The source directory.
+ * @param to The destination directory.
+ *
+ * @throws IOException for IO errors.
+ * @throws MojoExecutionException For plugin failures.
+ * @throws MojoFailureException For unexpected plugin failures.
+ */
+ private void copyDirectory(final File from, final File to)
+ throws IOException, MojoFailureException, MojoExecutionException
+ {
+ copyDirectory(from, to, null, null, null) ;
+ }
+
+ /**
+ * Copy a resource specification.
+ * @param resource The resource specification.
+ * @param to The destination directory.
+ * @param filterProperties The filter properties or null if no filtering.
+ *
+ * @throws IOException for IO errors.
+ * @throws MojoExecutionException For plugin failures.
+ * @throws MojoFailureException For unexpected plugin failures.
+ */
+ private void copyResource(final Resource resource, final File to, final Map filterProperties)
+ throws IOException, MojoFailureException, MojoExecutionException
+ {
+ final File resourceDir = new File(resource.getDirectory()) ;
+ final String absoluteResourceDir = resourceDir.getAbsolutePath() ;
+ final String absoluteToDir = to.getAbsolutePath() ;
+ if (absoluteResourceDir.startsWith(absoluteToDir))
+ {
+ getLog().warn("Ignoring embedded resource: " + absoluteResourceDir) ;
+ }
+ else
+ {
+ getLog().info("Copying esb resources to " + absoluteToDir) ;
+ final File targetDir ;
+ if (resource.getTargetPath() != null)
+ {
+ targetDir = new File(to, resource.getTargetPath()) ;
+ }
+ else
+ {
+ targetDir = to ;
+ }
+ copyDirectory(resourceDir, targetDir, toStringArray(resource.getIncludes()),
+ toStringArray(resource.getExcludes()), resource.isFiltering() ? filterProperties : null) ;
+ }
+ }
+
+ /**
+ * Copy a file.
+ * @param from The source file.
+ * @param to The destination file.
+ *
+ * @throws IOException for IO errors.
+ * @throws MojoExecutionException For plugin failures.
+ * @throws MojoFailureException For unexpected plugin failures.
+ */
+ private void copyFile(final File from, final File to)
+ throws IOException, MojoFailureException, MojoExecutionException
+ {
+ copyFile(from, to, null) ;
+ }
+
+ /**
+ * Copy a directory.
+ * @param from The source directory.
+ * @param to The destination directory.
+ * @param includes The source directory includes.
+ * @param excludes The source directory excludes.
+ * @param filterProperties The filter properties or null if no filtering.
+ *
+ * @throws IOException for IO errors.
+ * @throws MojoExecutionException For plugin failures.
+ * @throws MojoFailureException For unexpected plugin failures.
+ */
+ private void copyDirectory(final File from , final File to, final String[] includes, final String[] excludes, final Map filterProperties)
+ throws IOException, MojoFailureException, MojoExecutionException
+ {
+ final DirectoryScanner scanner = new DirectoryScanner() ;
+ scanner.setBasedir(from) ;
+ if (includes != null)
+ {
+ scanner.setIncludes(includes) ;
+ }
+ else
+ {
+ scanner.setIncludes(new String[] {DEFAULT_INCLUDES}) ;
+ }
+ if (excludes != null)
+ {
+ scanner.setExcludes(excludes) ;
+ }
+ scanner.addDefaultExcludes() ;
+ scanner.scan() ;
+
+ final String[] includedFiles = scanner.getIncludedFiles() ;
+ final int numIncludedFiles = (includedFiles == null ? 0 : includedFiles.length) ;
+ for(int count = 0 ; count < numIncludedFiles ; count++)
+ {
+ final String includedFile = includedFiles[count] ;
+ final File fromFile = new File(from, includedFile) ;
+ final File toFile = new File(to, includedFile) ;
+ copyFile(fromFile, toFile, filterProperties) ;
+ }
+ }
+
+ /**
+ * Copy a file.
+ * @param from The source file.
+ * @param to The destination file.
+ * @param filterProperties The filter properties or null if no filtering.
+ *
+ * @throws IOException for IO errors.
+ * @throws MojoExecutionException For plugin failures.
+ * @throws MojoFailureException For unexpected plugin failures.
+ */
+ private void copyFile(final File from, final File to, final Map filterProperties)
+ throws IOException, MojoFailureException, MojoExecutionException
+ {
+ getLog().info("Copying from " + from.getAbsolutePath() + " to " + to.getAbsolutePath()) ;
+ final File toParent = to.getParentFile() ;
+ if (!toParent.exists() && !toParent.mkdirs())
+ {
+ throw new MojoFailureException("Could not create target directory: " + toParent.getAbsolutePath()) ;
+ }
+
+ if (filterProperties != null)
+ {
+ final FileReader fromReader = new FileReader(from) ;
+ try
+ {
+ final Reader bufferedReader = new BufferedReader(fromReader) ;
+ final InterpolationFilterReader fromFilterReader = new InterpolationFilterReader(bufferedReader, filterProperties) ;
+ final FileWriter toWriter = new FileWriter(to) ;
+ try
+ {
+ IOUtil.copy(fromFilterReader, toWriter) ;
+ }
+ finally
+ {
+ toWriter.close() ;
+ }
+ }
+ finally
+ {
+ fromReader.close() ;
+ }
+ }
+ else
+ {
+ final long fromLastModified = from.lastModified() ;
+ if (to.lastModified() < fromLastModified)
+ {
+ final FileInputStream fromInputStream = new FileInputStream(from) ;
+ final InputStream bufferedInputStream = new BufferedInputStream(fromInputStream) ;
+ try
+ {
+ final FileOutputStream toOutputStream = new FileOutputStream(to) ;
+ try
+ {
+ IOUtil.copy(bufferedInputStream, toOutputStream) ;
+ }
+ finally
+ {
+ toOutputStream.close() ;
+ }
+ }
+ finally
+ {
+ fromInputStream.close() ;
+ }
+ to.setLastModified(fromLastModified) ;
+ }
+ }
+ }
+
+ /**
+ * Return an array of string representing the list.
+ * @param list The list of strings.
+ * @return The array of strings.
+ */
+ private String[] toStringArray(final List list)
+ {
+ if ((list != null) && !list.isEmpty())
+ {
+ return (String[])list.toArray(new String[0]) ;
+ }
+ return null ;
+ }
+
+ /**
+ * Get the filter properties used during copying.
+ * @param project The current maven project,
+ * @return The filter properties.
+ */
+ private Map getFilterProperties(final MavenProject project)
+ throws IOException
+ {
+ final Map properties = new ReflectionCompositeMap(project) ;
+
+ properties.putAll(System.getProperties()) ;
+ properties.putAll(project.getProperties()) ;
+
+ if (filters != null)
+ {
+ final Iterator filterIter = filters.iterator() ;
+ while(filterIter.hasNext())
+ {
+ final String filterPropertyFilename = (String)filterIter.next() ;
+ final File filterPropertyFile = new File(filterPropertyFilename) ;
+ if (filterPropertyFile.exists())
+ {
+ final FileInputStream fis = new FileInputStream(filterPropertyFile) ;
+ try
+ {
+ final Properties propFileProperties = new Properties() ;
+ propFileProperties.load(fis) ;
+ properties.putAll(propFileProperties) ;
+ }
+ finally
+ {
+ fis.close() ;
+ }
+ }
+ else
+ {
+ getLog().warn("Ignoring missing filter property file: " + filterPropertyFilename) ;
+ }
+ }
+ }
+
+ return properties ;
+ }
+
+ /**
+ * Get the name of the artifact.
+ * @param artifact The current artifact.
+ * @return The name of the artifact.
+ */
+ private String getArtifactName(final Artifact artifact)
+ {
+ final String artifactName ;
+ final String classifier = artifact.getClassifier() ;
+
+ if (StringUtils.isEmpty(classifier))
+ {
+ artifactName = artifact.getArtifactId() + '-' + artifact.getVersion() + '.' + artifact.getArtifactHandler().getExtension() ;
+ }
+ else
+ {
+ artifactName = artifact.getArtifactId() + '-' + artifact.getVersion() + '-' + classifier + '.' + artifact.getArtifactHandler().getExtension() ;
+ }
+ return artifactName ;
+ }
+}
Property changes on: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ESBMojo.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ReflectionCompositeMap.java
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ReflectionCompositeMap.java (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ReflectionCompositeMap.java 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.maven.plugin;
+
+import java.util.HashMap;
+
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
+
+/**
+ * This class implements a composite map constructed from the reflective
+ * contents of the maven project and any specified properties.
+ *
+ * N.B. This class does not support iteration over reflective properties.
+ *
+ * @author kevin
+ */
+public class ReflectionCompositeMap extends HashMap
+{
+ /**
+ * The serial version uid associated with this class.
+ */
+ private static final long serialVersionUID = 6760183520882987382L;
+
+ /**
+ * The maven project.
+ */
+ private final MavenProject project ;
+
+ /**
+ * Construct the reflection composite map.
+ * @param project The current maven project.
+ */
+ public ReflectionCompositeMap(final MavenProject project)
+ {
+ this.project = project ;
+ }
+
+ /**
+ * Return the value associated with the specified key.
+ * @param key The specified key.
+ * @return The value associated with the key or null if not associated.
+ */
+ public Object get(final Object key)
+ {
+ Object reflectiveValue = null ;
+ try
+ {
+ reflectiveValue = ReflectionValueExtractor.evaluate(String.valueOf(key), project) ;
+ }
+ catch (final Exception ex) {} // ignore
+
+ return (reflectiveValue != null ? reflectiveValue : super.get(key)) ;
+ }
+}
Property changes on: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/java/org/jboss/soa/esb/maven/plugin/ReflectionCompositeMap.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/META-INF/plexus/components.xml (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/META-INF/plexus/components.xml 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,57 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and individual contributors as indicated
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This 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 software 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 software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>esb</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <phases>
+ <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
+ <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
+ <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
+ <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
+ <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
+ <package>org.jboss.maven.plugins:maven-jboss-esb-plugin:esb</package>
+ <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+ <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
+ </phases>
+ </configuration>
+ </component>
+
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>esb</role-hint>
+ <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+ <configuration>
+ <classifier>esb</classifier>
+ <extension>esb</extension>
+ <type>esb</type>
+ <packaging>jar</packaging>
+ <language>java</language>
+ <addedToClasspath>true</addedToClasspath>
+ </configuration>
+ </component>
+ </components>
+</component-set>
Property changes on: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/main/resources/META-INF/plexus/components.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/index.apt
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/index.apt (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/index.apt 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,37 @@
+ ---
+ Introduction
+ ---
+ Kevin Conner
+ ---
+ 25th June 2007
+ ---
+
+~~JBoss, Home of Professional Open Source
+~~Copyright 2006, JBoss Inc., and individual contributors as indicated
+~~by the @authors tag. See the copyright.txt in the distribution for a
+~~full listing of individual contributors.
+~~
+~~This 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 software 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 software; if not, write to the Free
+~~Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+~~02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+JBoss Maven ESB Plugin
+
+ The JBoss Maven ESB plugin is responsible for creating an esb archive for use
+ with the JBossESB product. The plugin packages up classes, associated resources
+ and dependent artifacts into the correct structure.
+
+* Usage
+
+ Instructions on how to integrate this plugin can be found in the {{{usage.html}usage}} section.
\ No newline at end of file
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/usage.apt
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/usage.apt (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/apt/usage.apt 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,73 @@
+ ------
+ Introduction
+ ------
+ Kevin Conner
+ ------
+ 25th June 2007
+ ------
+
+~~JBoss, Home of Professional Open Source
+~~Copyright 2006, JBoss Inc., and individual contributors as indicated
+~~by the @authors tag. See the copyright.txt in the distribution for a
+~~full listing of individual contributors.
+~~
+~~This 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 software 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 software; if not, write to the Free
+~~Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+
+Usage
+
+ There are two ways in which this plugin can be used within maven
+
+ * specifying the packaging type.
+
+ * executing the <<<esb:esb>>> goal.
+
+ []
+ <<N.B.>> The Maven ESB plugin does not invoke the compilation phase,
+ this must be done prior to invoking the <<<esb:esb>>> goal.
+
+*Specifying the packaging type
+
+ The normal mechanism for executing this plugin is to specify a packaging
+ type of <<<esb>>> and to include the plugin within the plugins section.
+
+ The specification within the <<pom.xml>> would be as follows
+
++-----------------------------------------------+
+<project>
+ [...]
+ <groupId>groupId</groupId>
+ <artifactId>artifactId</artifactId>
+ <version>version</version>
+ <packaging>esb</packaging>
+ [...]
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jboss-esb-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ [...]
+ </plugins>
+ </build>
+</project>
++-----------------------------------------------+
+
+ The directory structure mirrors the standard jar hierarchy with the
+ only additional requirement being to include a META-INF/jboss-esb.xml.
+
+*Including dependent artifacts
+ Any dependent artifacts having <<<compile>>> or <<<runtime>>> scope will
+ be automatically included into the archive at the top level. The
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/fml/faq.fml
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/fml/faq.fml (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/fml/faq.fml 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,45 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and individual contributors as indicated
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This 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 software 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 software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<faqs id="faqs" title="Frequently Asked Questions">
+ <part id="GeneralFAQ">
+ <faq id="missingXMLFile">
+ <question>My ESB archive does not contain the jboss-esb.xml file, how do I fix this?</question>
+ <answer>
+ There are three ways to fix this.
+ <ul>
+ <li>include the jboss-esb.xml within the src/main/resources/META-INF directory.</li>
+ <li>override the location using the jbossEsbXml configuration element.</li>
+ <li>define the jboss-esb.xml within a filtered resource set.</li>
+ </ul>
+ </answer>
+ </faq>
+ <faq id="artifactDependencies">
+ <question>How do I include dependent artifacts in the archive?</question>
+ <answer>The plugin will inlcude all artifacts which are defined if the dependencies
+ section with a scope of compile or runtime.</answer>
+ </faq>
+ <faq id="furtherQuestions">
+ <question>Something not answered here?</question>
+ <answer>If there is something you would like to see in the FAQ then please contact the team.</answer>
+ </faq>
+ </part>
+</faqs>
Added: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/site.xml
===================================================================
--- labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/site.xml (rev 0)
+++ labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/site.xml 2007-06-27 07:37:38 UTC (rev 12887)
@@ -0,0 +1,32 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and individual contributors as indicated
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This 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 software 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 software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<project>
+ <body>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="Goals" href="plugin-info.html"/>
+ <item name="Usage" href="usage.html"/>
+ <item name="FAQ" href="faq.html"/>
+ </menu>
+ ${reports}
+ </body>
+</project>
Property changes on: labs/jbossesb/workspace/maven/maven-jboss-esb-plugin/src/site/site.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list