Pregunta

I'd like to add *.dlls as third party libs to my repository and during packaging process just pack them to *.jar, sign them and copy to some specific folder.


Signing and coping are well done and work correctly (as expected by using maven-dependency-plugin and maven-jarsigner-plugin). But I didn't find any method to automatically pack single dll to jar (without any sources like maven-assembly-plugin does).


Solution that I see by the time: add to my repository not a "pure" dll, but already packed to jar lib (packed by myself)... but it's not a good idea, I guess)

¿Fue útil?

Solución

It sounds like you've successfully retrieved your .dll (with dependency plugin) and signed it (jarsigner plugin), and it's somewhere in your ${project.build.directory} (which defaults to target).

If that's correct, give this a try:

  • Define the packaging of your project as jar
  • Retrieve dlls
  • Make sure the jarsigner:sign goal is bound to the prepare-package phase. It binds to package by default and we need to ensure jarsigner:sign runs before jar:jar.

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jarsigner-plugin</artifactId>
    <version>1.2</version>
    <executions>
      <execution>
        <id>sign</id>
        <phase>prepare-package</phase>       <!-- important -->
        <goals>
          <goal>sign</goal>
        </goals>
      </execution>
    </executions>
    </plugin>
    
  • Configure the jar plugin to include the signed dll(s)

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <executions>
      <execution>
        <!-- using this ID merges this config with default -->
        <!-- So it should not be necessary to specify phase or goals -->
        <!-- Change classes directory because it will look in target/classes 
             by default and that probably isn't where your dlls are.  If
             the dlls are in target then directoryContainingSignedDlls is
             simply ${project.build.directory}. -->
        <id>default-jar</id>   
        <configuration>
          <classesDirectory>directoryContainingSignedDlls</classesDirectory>
          <includes>
            <include>**/*.dll</include>
          </includes>
        </configuration>
      </execution>
    </executions>
    </plugin>
    
  • Now, running mvn clean package should give you a jar containing your signed dlls.

  • If JACOB requires manifest config there are docs explaining how to do this.

Good luck!

Otros consejos

I would recommend to pack your dll's as a zip archive via maven-assembly-plugin and let that module deploy the zip archive as attached to your usual pom. The packaging of that project should be pom instead of default. I would be a little bit confused if i download a jar and find dll's inside it, but if you prefer you could create jar via the maven-assembly-plugin or use the maven-jar-plugin.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top