Thanks again,
the exclusions did the trick and the following code now works:
/**
* To look up Archiver/UnArchiver implementations
*
* @component
* @required
*/
protected ArchiverManager archiverManager;
public void execute() throws MojoExecutionException,
MojoFailureException {
getLog().info("Packaging ESB application: ");
getLog().info("Project : " + artifactId);
getLog().info("Group : " + groupId);
getLog().info("Version : " + version);
getLog().info("Source : " + sourceDirectory);
getLog().info("Build : " + buildDirectory);
getLog().info("XAR : " + xarDirectory);
File archiveFile = new File(buildDirectory, finalName + ".xar");
try {
getLog().info("Creating archive : " + archiveFile.getAbsolutePath());
Archiver archiver = archiverManager.getArchiver("zip");
archiver.setDestFile(archiveFile);
//archiver.addDirectory(new File(buildDirectory, xarDirectory));
archiver.addDirectory(new File("generated-src/" + xarDirectory));
archiver.createArchive();
} catch(Exception e) {
throw new MojoExecutionException("Failed to create ESB archive " +
archiveFile.getAbsolutePath(), e);
}
}
My final question is...Where is the source of knowledge to know about
the inclusions / exclusions i would code in my pom? Is there a way of
telling or is it just experience ?
Thanks again
Andreas
Olivier Lamy schrieb:
If you use plexus-archiver you have to add some exclusions in your pom.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>1.0-alpha-9</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-api</artifactId>
</exclusion>
</exclusions>
</dependency>
--
Olivier
2008/7/28 Andreas Gies <[EMAIL PROTECTED]>:
Thank you for the hint,
I have changed my code so that it directly references the Archiver now. Now
I get the output below output from the plugin.
I think there might be an incompatibbility of the plugins. Perhaps someone
could give me a hint how I could debug this?
In general, if I want to use a component that has the Contextualize
interface implemented...do I need to pass the
Plexus context explicitly to that component or does the framework do this
magically. Moreover, the documentation
says that I *should* implement the Contextualize interface if I plan to use
plexus components. Even if I do this, the
contextualize method is never called ...
A pointer at a good example would really be great. For the acute problem I
have atteched My plugin code and the pom.xml.
Thanks
Andreas
[INFO] [ESBPlugin:package]
[INFO] Packaging ESB application:
[INFO] Project : iocc-esb-flow-pubopflightp
[INFO] Group : com.lhsystems.iocc
[INFO] Version : 1.0-SNAPSHOT
[INFO] Source :
E:\LHSys\maven\snapshots\com.lhsystems.iocc\iocc-esb-flow-pubopflightp\1.0-SNAPSHOT\src\main\ESB
[INFO] Build :
E:\LHSys\maven\snapshots\com.lhsystems.iocc\iocc-esb-flow-pubopflightp\1.0-SNAPSHOT\target
[INFO] XAR : xar
[INFO] Creating archive :
E:\LHSys\maven\snapshots\com.lhsystems.iocc\iocc-esb-flow-pubopflightp\1.0-SNAPSHOT\target\iocc-esb-flow-pubopflightp-1.0-SNAPSHOT.xar
[FATAL ERROR] com.sonicsw.maven.plugins.MavenEsbPackage#execute() caused a
linkage error (java.lang.IncompatibleClassChangeError) and may be
out-of-date. Check the realms:
[FATAL ERROR] Plugin realm =
app0.child-container[com.sonicsw.maven.plugins:ESBPlugin]
urls[0] = file:/C:/Documents and
Settings/agies/.m2/repository/com/sonicsw/maven/plugins/ESBPlugin/1.0-SNAPSHOT/ESBPlugin-1.0-SNAPSHOT.jar
urls[1] = file:/C:/Documents and
Settings/agies/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5.jar
urls[2] = file:/C:/Documents and
Settings/agies/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0-alpha-10/plexus-archiver-1.0-alpha-10.jar
urls[3] = file:/C:/Documents and
Settings/agies/.m2/repository/org/codehaus/plexus/plexus-component-api/1.0-alpha-15/plexus-component-api-1.0-alpha-15.jar
urls[4] = file:/C:/Documents and
Settings/agies/.m2/repository/org/codehaus/plexus/plexus-classworlds/1.2-alpha-6/plexus-classworlds-1.2-alpha-6.jar
urls[5] = file:/C:/Documents and
Settings/agies/.m2/repository/org/codehaus/plexus/plexus-io/1.0-alpha-2/plexus-io-1.0-alpha-2.jar
urls[6] = file:/C:/Documents and
Settings/agies/.m2/repository/com/sonicsw/pso/utilities/MFUtils/1.0-SNAPSHOT/MFUtils-1.0-SNAPSHOT.jar
urls[7] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/mgmt_client/7.6.0/mgmt_client-7.6.0.jar
urls[8] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/sonic_mgmt_client/7.6.0/sonic_mgmt_client-7.6.0.jar
urls[9] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/mgmt_config/7.6.0/mgmt_config-7.6.0.jar
urls[10] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/sonic_Client/7.6.0/sonic_Client-7.6.0.jar
urls[11] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/sonic_Crypto/7.6.0/sonic_Crypto-7.6.0.jar
urls[12] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-esb/xq_config/7.6.0/xq_config-7.6.0.jar
urls[13] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-esb/commons-logging/7.6.0/commons-logging-7.6.0.jar
urls[14] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-esb/xq_core/7.6.0/xq_core-7.6.0.jar
urls[15] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-esb/xbean/7.6.0/xbean-7.6.0.jar
urls[16] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-esb/jsr173_api/7.6.0/jsr173_api-7.6.0.jar
urls[17] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/xercesImpl/7.6.0/xercesImpl-7.6.0.jar
urls[18] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/MFdirectory/7.6.0/MFdirectory-7.6.0.jar
urls[19] = file:/C:/Documents and
Settings/agies/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar
urls[20] = file:/C:/Documents and
Settings/agies/.m2/repository/sonic-mq/mfcontext/7.6.0/mfcontext-7.6.0.jar
[FATAL ERROR] Container realm = plexus.core
urls[0] = file:/c:/tools/maven2/lib/maven-2.0.9-uber.jar
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] null
[INFO]
------------------------------------------------------------------------
[INFO] Trace
java.lang.IncompatibleClassChangeError
at
org.codehaus.plexus.archiver.zip.AbstractZipArchiver.createArchiveMain(AbstractZipArchiver.java:324)
at
org.codehaus.plexus.archiver.zip.AbstractZipArchiver.execute(AbstractZipArchiver.java:249)
at
org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:762)
at
com.sonicsw.maven.plugins.MavenEsbPackage.execute(MavenEsbPackage.java:46)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Mon Jul 28 18:52:22 CEST 2008
Olivier Lamy schrieb:
Hi,
It looks you want a zipArchiver.
You can use :
/**
* The Jar archiver.
*
* @parameter
expression="${component.org.codehaus.plexus.archiver.Archiver#zip}"
* @required
*/
private ZipArchiver zipArchiver;
Or with the new annotation
/**
* The Jar archiver.
*
* @component role="org.codehaus.plexus.archiver.Archiver"
roleHint="zip"
* @required
*/
private ZipArchiver zipArchiver;
HTH,
--
Olivier
2008/7/27 Andreas Gies <[EMAIL PROTECTED]>:
Hello,
I am inteh process of writing a series of plugins. The last plugin is
supposed to package some generated sourcefiles into an archive.
I was thinking to reuse the Archiver Component from the plexus libraries
for
this. So my code looks like this:
package com.sonicsw.maven.plugins;
import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
/**
* Packaging an ESB application.
*
* @goal package
*/
public class MavenEsbPackage extends AbstractESBMojo {
/**
* To look up Archiver/UnArchiver implementations
*
* @parameter
expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
*/
protected ArchiverManager archiverManager;
public void execute() throws MojoExecutionException,
MojoFailureException {
getLog().info("Packaging ESB application: ");
getLog().info("Project : " + artifactId); getLog().info("Group : "
+
groupId); getLog().info("Version : " + version);
getLog().info("Source : " + sourceDirectory);
getLog().info("Build : " + buildDirectory);
getLog().info("XAR : " + xarDirectory);
File archiveFile = new File(buildDirectory, finalName + ".xar");
try {
getLog().info("Creating archive : " + archiveFile.getAbsolutePath());
Archiver archiver = archiverManager.getArchiver("zip");
archiver.setDestFile(archiveFile);
//archiver.addDirectory(new File(buildDirectory, xarDirectory));
archiver.addDirectory(new File("generated-src/" + xarDirectory));
archiver.createArchive();
} catch(Exception e) {
throw new MojoExecutionException("Failed to create ESB archive " +
archiveFile.getAbsolutePath(), e);
}
}
}
However, when I try to retrieve the Archiver, I get a NPE:
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to create
ESB
archive
E:\LHSys\maven\snapshots\com.lhsystems.iocc\iocc-esb-flow-pubopflightp\1.0-SNAPSHOT\target\iocc-esb-flow-pubopflightp-1.0-SNAPSHOT.xar
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to
create
ESB archive
E:\LHSys\maven\snapshots\com.lhsystems.iocc\iocc-esb-flow-pubopflightp\1.0-SNAPSHOT\target\iocc-esb-flow-pubopflightp-1.0-SNAPSHOT.xar
at
com.sonicsw.maven.plugins.MavenEsbPackage.execute(MavenEsbPackage.java:49)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
Caused by: java.lang.NullPointerException
at
org.codehaus.plexus.archiver.manager.DefaultArchiverManager.getArchiver(DefaultArchiverManager.java:60)
at
com.sonicsw.maven.plugins.MavenEsbPackage.execute(MavenEsbPackage.java:41)
... 18 more
It seems that the ArchiverManager doesn't know about the Plexus Context
(looking at (DefaultArchiverManager.java:60) ). I am guessing that I miss
a
basic initialization step in order to reuse a component.
Am I missing something?--Could you perhaps point me to more documentation
on
reusing components in a plugin (I have read the
http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook and
the
Mojo tutorial ...).
Thanks in advance
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]