We have been using the wonderful flex mojos to build some of our actionscript code.
i needed to publish a jar containing the asdocs, but alas, the asdoc plugin doesn’t contain an equivalent to the javadoc:jar goal from the javadoc plugin.
needing something immediately, GMaven to the rescue!
the below profile will generate an attached jar when running mvn -P release
release
info.flex-mojos
asdoc-mojo
package
attach-asdocs
asdoc
org.codehaus.groovy.maven
gmaven-plugin
1.0-rc-3
package-asdoc
package
execute
org.codehaus.plexus
plexus-archiver
org.apache.maven
maven-archiver
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.archiver.MavenArchiveConfiguration;
File asDocJar = new File(project.build.directory, "${project.build.finalName}-asdoc.jar")
if( asDocJar.exists() ) asDocJar.delete()
archiver = new MavenArchiver()
archiver.archiver = new JarArchiver()
archiver.outputFile = asDocJar
archiver.archiver.addDirectory( new File(project.build.directory, "site/asdocs") )
archive = new MavenArchiveConfiguration()
archive.addMavenDescriptor = false
archiver.createArchive( project, archive )
helper = session.lookup("org.apache.maven.project.MavenProjectHelper")
// need to attach to the *original* project
// http://jira.codehaus.org/browse/MGROOVY-172
project.class.getDeclaredField("original").accessible = true
helper.attachArtifact( project.original, "zip", "asdoc", asDocJar )
org.codehaus.plexus
plexus-archiver
1.0-alpha-7
org.apache.maven
maven-archiver
2.3
Tags: code, development
July 9th, 2009 at 8:59 am
Hi, thanks for this.
If you use Maven 2.2.0 and Gmaven 1.0-rc5, which are currently the last versions for each, then you need to replace
project.class.getDeclaredField(”original”).accessible = true
helper.attachArtifact( project.original, “zip”, “asdoc”, asDocJar )
with
helper.attachArtifact( project.getDelegate(), “zip”, “asdoc”, asDocJar )
otherwise, you get the following error:
NoSuchFieldError: original
hope this helps someone avoiding my struggle
regards,
Wim
March 5th, 2012 at 11:29 am
Latest maven 3.0.4/ gmaven 1.4 doesn’t need set field accessible any more:
def mavenProjectHelper = session.lookup(”org.apache.maven.project.MavenProjectHelper”)
mavenProjectHelper.attachArtifact( project, “zip”, “asdoc”, asDocJar )