简体   繁体   English

intellij中是否有一个插件可以打包项目中的所有内容并创建一个shell脚本来启动应用程序?

[英]Is there a plugin in intellij that packages everything in a project and creates a shell script to launch the application?

This seems like a straight forward plugin, I wonder if it already exists (yeah, I searched). 这看起来像一个直接的插件,我想知道它是否已经存在(是的,我搜索过)。 I have a project with some lib dependencies. 我有一个带有一些lib依赖项的项目。

What I'm looking for does the following: 我正在寻找的是以下内容:

  1. jars up classes built from your source code into one or more jars 将根据源代码构建的类放入一个或多个jar中
  2. gathers up the jar files your source depends on 收集源所依赖的jar文件
  3. creates a little shell script to set the classpath to the dependencies, and launches your main class. 创建一个小shell脚本以将类路径设置为依赖项,并启动您的主类。
  4. zips all this up in a neat little package so you can take this zip/tar and deploy it, say on another machine. 将所有这些打包在一个整洁的小包中,这样你就可以使用这个zip / tar并在另一台机器上进行部署。

Surely someone has written a simple deployer like this? 当然有人写了这样一个简单的部署者? I can't find one in the plugins repo 我在插件回购中找不到一个

I am not sure if IntelliJ has something like that, but Maven surely does what you need. 我不确定IntelliJ是否有类似的东西,但Maven肯定会做你需要的。 You can use Maven ( http://maven.apache.org/ ) with the Assembly plugin ( http://maven.apache.org/plugins/maven-assembly-plugin/ ). 您可以使用Maven( http://maven.apache.org/ )和Assembly插件( http://maven.apache.org/plugins/maven-assembly-plugin/ )。 With some easy configuration you will get Maven to package a zip file for you with all the required JAR files in a subfolder. 通过一些简单的配置,您将获得Maven为您打包一个zip文件,并在子文件夹中包含所有必需的JAR文件。 Then you can run the application with some script like the one below: 然后你可以用一些脚本运行应用程序,如下所示:

execute.cmd:
%JAVA_HOME%\bin\java -Xms512m -Xmx512m -classpath "../lib/*" yourPackage.YourClassName

The script above assumes a pre-defined JAVA_HOME environment variable. 上面的脚本假定了一个预定义的JAVA_HOME环境变量。 There are other options such as WinRun4J to launch your application. 还有其他选项,如WinRun4J,可以启动您的应用程序。

Maven is a pretty awesome tool - not only you can generate a ZIP file with everything from the command line, but you can also manage all your application dependencies, and it integrates nicely with a broad range of SCM tools to give you powerful tools, like the release plugin ( http://maven.apache.org/plugins/maven-release-plugin/ ) and others. Maven是一个非常棒的工具 - 不仅可以从命令行生成包含所有内容的ZIP文件,而且还可以管理所有应用程序依赖项,并且它与各种SCM工具很好地集成,为您提供强大的工具,如发布插件( http://maven.apache.org/plugins/maven-release-plugin/ )等。

Such tool was created several years ago and is called BuildDesk . 这种工具是几年前创建的,称为BuildDesk However, it was not very popular and the project was discontinued (no updates since 2009). 然而,它并不是很受欢迎,该项目已经停止(自2009年以来没有更新)。 I don't know if it's still compatible with the current IntelliJ IDEA version. 我不知道它是否仍然与当前的IntelliJ IDEA版本兼容。

At the moment the solution is to use Maven, Ant or a combination of them with the built-in Artifacts feature . 目前解决方案是使用Maven,Ant或它们与内置Artifacts功能的组合 IDEA can already create an executable Jar with all the required dependencies, the only extra you need is a shell script or an executable wrapper like launch4j or Exe4j . IDEA已经可以创建一个具有所有必需依赖项的可执行Jar,您需要的唯一额外内容是shell脚本或可执行包装器,如launch4jExe4j If you have a service, consider JavaServiceWrapper . 如果您有服务,请考虑JavaServiceWrapper

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM