Hi!

I would like to use the following code to extract an EAR and all of its jars 
inside a Mojo.

    /**
     * The archive manager.
     * @component
     * @required
     */
    private ArchiverManager archiverManager;
....

        UnArchiver unArchiver = archiverManager.getUnArchiver( "zip" );
        unArchiver.setSourceFile( source );
        unArchiver.setDestDirectory( destDir );
        unArchiver.extract();

But I get NPE. It seems that in DefaultArchiverManager the contextualize method 
wasn't called.
I also tried the exclusions around dependency declaration, but does not work.
I have no idea how to use the plexus component.

At least some ideas, which classes should I use to unpack an EAR and its jars. 
I have to transfer some stubs generated by WebSphere EjbDeploy blackbox which 
does not create correct client jar.

Thanks
Tibor
________________________________________
Feladó: Andreas Gies [EMAIL PROTECTED]
Küldve: 2008. július 28. 19:17
Címzett: Maven Users List
Tárgy: [SPAM] - Re: Using a Pleus component in a plugin - Bayesian Filter 
detected spam

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
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to