【问题标题】:Package Dll in Jar using Maven- single goal使用 Maven 将 Dll 打包到 Jar 中 - 单一目标
【发布时间】:2012-07-19 16:53:33
【问题描述】:

我在我的 maven 项目中添加了一个 DLL 作为这样的依赖项:

<dependency>
  <groupId>com.test.dll</groupId>
  <artifactId>myDll</artifactId>
  <version>0.1</version>
  <type>dll</type>
</dependency>

当我尝试执行maven:install

它给了我这个错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-   
beta-5:single (jar-with-dependencies) on project testApp: Failed to create 
assembly:    Error adding file-set for 'com.test.dll:myDll:dll:0.1' to archive: Error 
 adding archived file-set. PlexusIoResourceCollection not found for: C:\Users\USER\.m2
 \repository\com\test\dll\myDll\0.1\myDll-0.1.dll: No such archiver: 'dll'

我在这里做错了什么??

更新

 <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>   
        <executions>
        <execution>
        <goals>
            <goal>sign</goal>
        </goals>
        </execution>
       </executions>
       <configuration>
        <keystore>src/main/keystore/mykey.keystore</keystore>
        <alias>aliasname</alias>
        <storepass>passw0rd</storepass>                  
        <verify>true</verify>

    </configuration>        
    </plugin>               
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>      
        <executions>
            <execution>
                <id>jar-with-dependencies</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>single</goal>
                </goals>       
            <configuration>
            <archive>
                <manifest>

                </manifest>
            </archive>              
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>           
            <appendAssemblyId>false</appendAssemblyId>
        </configuration>
    </execution>     
  </executions>      
  </plugin>   
 </plugins> 

【问题讨论】:

  • 能否请您发布 DLL pom.xml,以及您的程序集文件。
  • @Jean-Rémy :谢谢 jean,但我没有任何单独的程序集文件..上面发布了 dll 的 dependency 部分。
  • 那么,你可以使用完整的 pom 吗?错误提到了 maven-assembly-plugin。如果你没有汇编文件,我想知道为什么。
  • 看起来您遇到了与here 类似的问题。您至少需要为您使用的插件提供 sn-ps,以便有人帮助您。从表面上看,这似乎是 maven 试图 unpack dll 的问题。
  • @Raghuram :谢谢,已经用plugins 部分更新了我的问题。

标签: maven maven-2 m2e eclipse-juno


【解决方案1】:

为了补充 Stefan 的回答,我认为您不想为您的这个项目做一个 jar-with-dependencies 打包。您应该考虑使用 bin 包装之一(如 .zip 或 tar.gz)

【讨论】:

    【解决方案2】:

    这里的问题是jar-with-dependencies 描述符。描述符unpacks将所有依赖项放到一个目录中,并将这个目录打包成一个新的JAR文件。但是,它无法解压缩 DLL 文件(即“没有这样的归档程序”错误消息)。要使其正常工作,您需要定义自己的程序集描述符:

    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    
      <id>assembly-with-dll</id>
      <formats>
        <format>jar</format>
      </formats>
      <includeBaseDirectory>false</includeBaseDirectory>
      <dependencySets>
        <!-- package the regular dependencies -->
        <dependencySet>
          <outputDirectory>/</outputDirectory>
          <useProjectArtifact>true</useProjectArtifact>
          <unpack>true</unpack>
          <scope>runtime</scope>
          <!-- exclude the DLL -->
          <excludes>
            <exclude>com.example:my-dll</exclude>
          </excludes>
        </dependencySet>
        <!-- package the DLLs -->
        <dependencySet>
          <outputDirectory>/</outputDirectory>
          <includes>
            <include>com.example:my-dll</include>
          </includes>
        </dependencySet>
      </dependencySets>
    </assembly>
    

    假设上面的描述符位于src/main/assembly,maven-assembly-plugin 的配置如下:

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <executions>
            <execution>
              <id>jar-with-dependencies</id>
              <phase>prepare-package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                <descriptor>src/main/assembly/assembly.xml</descriptor>
                <appendAssemblyId>false</appendAssemblyId>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
    

    【讨论】:

      【解决方案3】:

      这里有一条信息:Maven Dll Dependency Problem。 要解决此问题,请从您的程序集中排除 dll:

      <excludes>
          <exclude>*:dll*</exclude>
      </excludes>
      

      上次我必须创建一个带有依赖项的可执行 jar,我将它们从 jar 中取出,放在 lib 目录中。 DLL 必须是:

      • 在应用程序类路径中(例如服务器的 server/lib)
      • 或在操作系统类路径中(例如 C:\Windows\system32)

      看完你的pom和dependecy文件集,我可能会更准确:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-27
        • 2017-01-21
        • 2013-02-15
        • 1970-01-01
        • 2014-02-05
        • 1970-01-01
        • 2011-04-03
        • 1970-01-01
        相关资源
        最近更新 更多