Additionally, it's possible to specify a mixture of descriptors and descriptorRefs within the same configuration. Sauf si vous avez besoin du "maven-assembly-plugin" pour des raisons autres que le réglage de la mainClass, vous pouvez utiliser le " maven-jar-plugin ' plugin. In order for this discussion to be useful, it's critical to cover two topics: configuration of the plugin - both inside the POM and, where possible, from the command line - and the different execution styles. We can tell the Assembly Plugin to use that instead: Again, note that we could specify multiple custom assembly descriptors here. For example, imagine that our project produces a jar. To bind the single goal to a project's build lifecycle, you can add this configuration (assuming you're using the jar-with-dependencies prefabricated descriptor): Then, to create a project assembly, simple execute the normal package phase from the default lifecycle: When this build completes, you should see a file in the target directory with a name similar to the following: Notice the artifact classifier, between the end of the version and the beginning of the file extension, jar-with-dependencies. For more information, see the examples section or the plugin parameter documentation. Using this configuration, it's easy to configure the Main-Class attribute of the jar manifest: If we add this configuration to the attached mojo example above and rebuild, we will see an entry like this in the META-INF/MANIFEST.MF file of the resulting jar: For more information on advanced configuration for the Assembly Plugin, see the Resources section. Copyright ©2002–2020
Getting started with the Assembly Plugin is pretty simple. I have been trying, for several days now, to create an executable jar file for my muli-module maven project, sadly I have had no luck on doing it. You can construct an assembly directory directly from the command line by executing: When completed, you should see a directory structure similar to this: If you need to ensure that assemblies are produced whenever your project builds, or when a particular profile is activated (also useful for configuring other plugins during this special process), then the following two mojos are probably what you're looking for. Existe-t-il un moyen d'inclure toutes les dépendances DANS le jar généré en exécutant l'objectif jfx: jar pour le plugin javafx maven? By contrast, the attached mojo assumes that the build has already produced project binaries or whatever else it needs prior to building the assembly itself. For more information on writing your own assembly descriptor, read the. Alternatively, we've created a custom assembly descriptor called src.xml in the src/assembly directory (see the Resources section for more information), we can tell the Assembly Plugin to use it instead: Again, note that we could specify multiple custom assembly descriptors here. Once you've configured the various descriptors and descriptorRefs for the assemblies you want the project to produce, it's time to determine how you want to build them. To handle filtering this version of Maven Assembly Plugin uses Maven Filtering 3.1.1. Apache Maven Assembly plugin allows to create an executable jar which includes all its dependencies within it. In JavaS W, an executable jarW file specifies its main class in the MANIFEST.MF file in that jar file. The attached and directory-inline mojos are functional counterparts of the mojos discussed above, except that they are meant to bind into the default build lifecycle. This is the id of the assembly descriptor used to create this artifact. [Java]Maven Assembly Pluginで実行可能(Executable)なjarを作成する 使い方 Javaプログラムをコマンドラインから実行するには、依存するライブラリを全てまとめて実行可能なjarファイル(Executable jar)を作るのが便利です。 Once you've configured the various descriptors and descriptorRefs for the assemblies you want the project to produce, it's time to build them. To accommodate this, the Assembly Plugin supports configuration of an element which is identical to that supported by the maven-jar-plugin (see Resources). 方法二:使用maven-assembly-plugin插件打包