Java maven打包应用程序jar,创建项目类路径,目标

Java maven打包应用程序jar,创建项目类路径,目标,java,eclipse,swing,maven,Java,Eclipse,Swing,Maven,更新:通过使用汇编插件将工件复制到文件夹或创建可再发行的zip文件来解决。 我不认识马文。使用STS/eclipse创建了一个maven项目,它是一个swing独立应用程序。应用程序在STS内部运行良好。 {弄清楚它是如何获得runner脚本的。模板在源代码中。maven只需过滤它并放入当前的jar名称。现在只需要弄清楚如何停止maving将我的应用程序jar放入程序集库希望它上升一级,以便可以单击它并启动,库中还有80个其他jar,现在使用ant进行此操作} 原始问题 找不到lib文件夹。显然

更新:通过使用汇编插件将工件复制到文件夹或创建可再发行的zip文件来解决。 我不认识马文。使用STS/eclipse创建了一个maven项目,它是一个swing独立应用程序。应用程序在STS内部运行良好。 {弄清楚它是如何获得runner脚本的。模板在源代码中。maven只需过滤它并放入当前的jar名称。现在只需要弄清楚如何停止maving将我的应用程序jar放入程序集库希望它上升一级,以便可以单击它并启动,库中还有80个其他jar,现在使用ant进行此操作}

原始问题 找不到lib文件夹。显然,该应用程序引用了maven local repo中的本地JAR

我可以告诉maven将它们复制到我的项目下的某个文件夹中,比如dist/lib,并在我的dist中创建一个完整的应用程序jar/我不在乎dist是否是其他目录名->如果存在maven默认值,请不要介意。我想要一套可分发的罐子

当我现在构建我的项目时,它将类放在

/目标/类别

目录。/这里是我的项目文件夹

我的pom:-

然后:-

[INFO] Including org.seleniumhq.selenium:selenium-safari-driver:jar:2.33.0 in the shaded jar.
[INFO] Including org.seleniumhq.selenium:selenium-support:jar:2.33.0 in the shaded jar.
[INFO] Including org.webbitserver:webbit:jar:0.4.14 in the shaded jar.
[INFO] Including xalan:serializer:jar:2.7.1 in the shaded jar.
[INFO] Including stax:stax-api:jar:1.0.1 in the shaded jar.
[INFO] Including xalan:xalan:jar:2.7.1 in the shaded jar.
[INFO] Including xerces:xercesImpl:jar:2.10.0 in the shaded jar.
[INFO] Including xml-apis:xml-apis:jar:1.4.01 in the shaded jar.
[INFO] Including org.apache.xmlbeans:xmlbeans:jar:2.3.0 in the shaded jar.
[DEBUG] Processing JAR /Users/manoj/Downloads/SA/target/SA-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.873s
[INFO] Finished at: Sat Jul 06 22:08:17 GMT+05:30 2013
[INFO] Final Memory: 20M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default-cli) on project SA: Error creating shaded jar: Invalid signature file digest for Manifest main attributes -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default-cli) on project SA: Error creating shaded jar: Invalid signature file digest for Manifest main attributes
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    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:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: Invalid signature file digest for Manifest main attributes
    at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:528)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:221)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:288)
    at java.util.jar.JarVerifier.update(JarVerifier.java:199)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:323)
    at java.util.jar.JarFile.getInputStream(JarFile.java:388)
    at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:146)
    at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:458)
    ... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
使用此处描述的John Ament建议的装配或

所有的罐子都有很大的柏油和拉链。大部分工作已经完成。现在只需要解包,制作一个脚本,这样我就可以

 project-home
   -> dist
   -->   MyApp.jar
   --> lib
   --->  other1.jar
   --->  other2.jar
   --> conf
   --->  myResources1.jpg
   --->  otherFiles2.xyz
通过将以下内容添加到插件部分来创建UberJar:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.1</version>
    <configuration>
      <!-- put your configurations here -->
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
Maven将在jar上创建一个包含所有源类和所有依赖项的类。

通过将其添加到插件部分来创建一个UberJar:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.1</version>
    <configuration>
      <!-- put your configurations here -->
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
      </execution>
    </executions>
  </plugin>


Maven将在jar上创建一个包含所有源类和所有依赖项的类。

虽然shade是一个很好的解决方案,但您可能不希望jar中包含这些依赖项。您还可以使用assembly插件将工件复制到文件夹中或创建可再发行的zip文件。

虽然shade是一个很好的解决方案,但您可能不希望JAR中存在这些依赖项。您还可以使用assembly插件将工件复制到文件夹或创建可再发行的zip文件。

+1感谢您的快速回答。但当我选择从STS项目中清理和构建时,并没有创建任何新的内容。转到命令行,但出现其他错误。我需要先做些什么才能告诉它打包吗?请参阅问题了解新问题无效签名可能来自其中一个罐子。查看插件网页并进入配置。我们可以从JAR中排除文件,因此您可以尝试排除有问题的清单。mvn软件包应该足够了,shade已经绑定到了生命周期阶段,请参阅executionGoing with assembly,因为我不知道如何找到那个坏罐子,assembly满足了我的基本要求->让maven将所有罐子复制到一个地方。+1感谢您的快速回答。但当我选择从STS项目中清理和构建时,并没有创建任何新的内容。转到命令行,但出现其他错误。我需要先做些什么才能告诉它打包吗?请参阅问题了解新问题无效签名可能来自其中一个罐子。查看插件网页并进入配置。我们可以从JAR中排除文件,因此您可以尝试排除有问题的清单。mvn包应该足够了,shade已经绑定到了生命周期阶段请参见executionGoing with assembly,因为我不知道如何找到那个坏罐子,assembly满足了我的基本要求->让maven将所有罐子复制到一个地方。看起来shade是一种方法。是否还有其他方法可以将所有lib转储到一个单独的目录中,生成一个app.jar和一个包含所有lib的类路径的sh或文本文件?看起来当前的错误是/META-INF中有一个名为LICENSE的文件,maven希望创建一个名为toolooks的目录,就像shade是一种方法一样。是否还有其他方法可以将所有lib转储到一个单独的目录中,生成一个app.jar和一个包含所有lib的类路径的sh或文本文件?看起来当前的错误是在/META-INF中有一个名为LICENSE的文件,maven希望创建一个名为tooBTW的目录,下面是汇编的简要介绍。请注意,程序集内容仍保留在外部。这似乎可以正常工作。现在来弄清楚!我想我需要用最终的app jar制作一些东西,并告诉它在lib文件夹中包含所有依赖项的二进制文件?然后看看如何制作一个类路径,并用它来启动脚本!工作原理:它创建了一个SA-0.0.1-SNAPSHOT-default.tar.gz,它有一个包含所有依赖jar的lib。是:-现在任何帮助,使脚本包括所有库。使用蚂蚁?maven中有什么吗?您不能将依赖项声明为清单条目来实现这一点吗?这应该是组装的一部分?顺便说一句,这里有一个组装的快速介绍。请注意,程序集内容仍保留在外部。这似乎可以正常工作。现在来弄清楚!我想我需要用最终的app jar制作一些东西,并告诉它在lib fo中包含所有依赖项的二进制文件
阿尔德尔?然后看看如何制作一个类路径,并用它来启动脚本!工作原理:它创建了一个SA-0.0.1-SNAPSHOT-default.tar.gz,它有一个包含所有依赖jar的lib。是:-现在任何帮助,使脚本包括所有库。使用蚂蚁?maven中有什么吗?您不能将依赖项声明为清单条目来实现这一点吗?这应该是组件的一部分吗?
 project-home
   -> dist
   -->   MyApp.jar
   --> lib
   --->  other1.jar
   --->  other2.jar
   --> conf
   --->  myResources1.jpg
   --->  otherFiles2.xyz
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.1</version>
    <configuration>
      <!-- put your configurations here -->
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
      </execution>
    </executions>
  </plugin>