标签: maven-assembly-plugin

如何在 Maven 程序集的 basedir 中包含所有文件(不是目录)

在如下所示的 Maven 程序集中,结果是发生递归,重新包含基目录。

以下失败实际上消耗了 cpu 并且不返回:

<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>deploy</id>
  <baseDirectory>hive</baseDirectory>
    <includeBaseDirectory></includeBaseDirectory>
    <formats>
    <format>zip</format>
  </formats>
  <fileSets>
        <fileSet>
            <directory>${basedir}/lib</directory>
            <outputDirectory>lib</outputDirectory>
        </fileSet>
      <fileSet>
            <directory>${basedir}</directory>
            <outputDirectory></outputDirectory>
        </fileSet>
  </fileSets>
  <files>
    <file>
        <source>${basedir}/target/${project.build.finalName}.jar</source>
        <outputDirectory>lib</outputDirectory>
    </file>
  </files>
</assembly>
Run Code Online (Sandbox Code Playgroud)

如果没有包含基目录,则 lib/* 下的文件将被正确包含并且汇编成功。那么..这里正确的语法是什么?谢谢!

以下构建了一个输出 zip,但没有基本目录中的文件 - 所以它不完整:

    <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>deploy</id>
  <baseDirectory>hive</baseDirectory>
    <includeBaseDirectory></includeBaseDirectory>
    <formats>
    <format>zip</format>
  </formats>
  <fileSets>
        <fileSet>
            <directory>${basedir}/lib</directory>
            <outputDirectory>lib</outputDirectory>
        </fileSet>
  </fileSets>
  <files>
    <file>
        <source>${basedir}/target/${project.build.finalName}.jar</source>
        <outputDirectory>lib</outputDirectory>
    </file>
  </files>
</assembly>
Run Code Online (Sandbox Code Playgroud)

maven maven-assembly-plugin

3
推荐指数
1
解决办法
8000
查看次数

Maven 程序集插件 - 如何生成具有自定义文件扩展名的工件?

我正在生产一个foo.bar.zip从以下命名的工件......

我的 pom.xml 插件条目如下所示:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <descriptor>src/assembly/bin.xml</descriptor>
        <finalName>foo.bar</finalName>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
        </execution>
    </executions>
</plugin> 
Run Code Online (Sandbox Code Playgroud)

我的描述符文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<formats>
    <format>zip</format>
</formats>
<fileSets>

etc. etc. 
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何生成带有自定义扩展名的文件?例如使用名称foo.bar而不是foo.bar.zip.

maven maven-assembly-plugin

3
推荐指数
2
解决办法
1314
查看次数

Maven 程序集:生成资源 zip 文件并将其包含到主程序集 zip 文件中

如何使用 Maven Assembly 插件将生成的 zip 文件包含到zip 文件中?

例如,我有以下文件夹结构:

./folderA/
./file1
Run Code Online (Sandbox Code Playgroud)

我想生成一个 zip 文件,其中的内容是这样的:

folderA.zip
file1
Run Code Online (Sandbox Code Playgroud)

这是我的简化配置':

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project >
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptor>${basedir}/assembly-zipFolderA.xml</descriptor>
                    <finalName>folderA.zip</finalName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptor>${basedir}/assembly.xml</descriptor>
                    <finalName>${module-zipFinalName}</finalName>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

程序集zipFolderA.xml

<assembly>
    <id>folderA-zip</id>
    <includeBaseDirectory>false</includeBaseDirectory>
    <formats>
        <format>zip</format>
    </formats>

    <fileSets>
        <fileSet>
            <directory>folderA</directory>
            <outputDirectory>/</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)

程序集.xml

<assembly>
    <id>main</id>
    <includeBaseDirectory>false</includeBaseDirectory>
    <formats>
        <format>zip</format>
    </formats>

    <files>
        <file>
            <source>file1</source>
        </file>
        <file>
            <source>folderA.zip</source>
        </file>
    </files>
</assembly>
Run Code Online (Sandbox Code Playgroud)

===>使用这个配置,Maven 抱怨它找不到 …

maven maven-assembly-plugin

3
推荐指数
1
解决办法
7784
查看次数

使用 Maven Assembly 插件合并 META-INF/services 文件

我正在寻找一种合并META-INF/services文件的方法,例如META-INF/services/javax.ws.rs.ext.Providers,在jar-with-dependencies使用 Maven Assembly 插件构建时。我找到了显示如何使用 Maven Shade 插件做到这一点的答案。不幸的是,我们已经广泛使用了 Mave Assembly 插件,目前还不清楚我们如何插入 Maven Shade 插件......。

java maven maven-assembly-plugin

3
推荐指数
1
解决办法
2271
查看次数

如何在 Maven 中只构建 jar-而不包含依赖项?

我正在编译 Kotlin(JRE) 并将其部署到一个小机器人上。我非常幸运地创建了一个带有依赖项的 jar,谢谢 StackOverflow。

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <mainClass>${project.main.class}</mainClass>
            </manifest>
        </archive>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

但罐子很大,大约有 25mb 大。没有依赖项的 jar 大小是完全合理的 26kb,这确实很重要,因为打包那个大 JAR 很慢,然后我scp每次都必须将其部署到机器人。

我能够将所有依赖项预加载到机器人上的一个文件夹中,通过mvn dependency:copy-dependencies并将它们复制过来。(再次感谢 StackOverflow)。现在我需要一种简单的方法来设置一个属性,使其只需编译和复制即可target/MYBOT-1.0-SNAPSHOT.jar,而不必target/MYBOT-1.0-SNAPSHOT-jar-with-dependencies.jar每次都尝试编译文件。

maven maven-assembly-plugin

3
推荐指数
1
解决办法
9655
查看次数

Maven个人资料ID如何使用var?

个人资料是:我使用$ {artifactId}作为个人资料ID。

 <profiles>
    <profile>
        <id>${artifactId}</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <descriptors>
                            <descriptor>distribution.xml</descriptor>
                        </descriptors>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
Run Code Online (Sandbox Code Playgroud)

在shell中运行Maven: mvn -U -Dmaven.test.skip=true -f pom.xml -Pabc_test clean install

然后我发现一个错误:

[警告]所请求的配置文件“ abc_test”不存在,因此无法激活。完

maven maven-assembly-plugin

2
推荐指数
1
解决办法
5201
查看次数

Maven程序集:包含与baseDirectory相同级别的文件

我正在使用程序集插件将我的swing应用程序与artifactId killer-app打包并使用自定义程序集描述符.

程序集工作正常,我可以/killer-app/在程序集内的目录中包含我想要的任何内容.

killer-app-archive.zip
 \- killer-app
    \- whatever ...
Run Code Online (Sandbox Code Playgroud)

问题是我必须/killer-app/在存档内的文件夹的同一级别包含另一个文件.

killer-app-archive.zip
 \- killer-app
 |  \- whatever ...
 \- launch.bat
Run Code Online (Sandbox Code Playgroud)

我一直试着玩

<includeBaseDirectory>假</ includeBaseDirectory>

但这只是删除/killer-app/我必须保留的文件夹.

maven maven-assembly-plugin

2
推荐指数
1
解决办法
7073
查看次数

仅在子POM上执行maven程序集插件

我有一个带有父POM和三个子项目的项目.我想执行目标程序集:仅在一个子POM上进行程序集.我已经阅读了以下帖子,但我没有让它与maven程序集插件一起工作.

在子模块上执行Maven插件目标,但不在父模块上执行

如果我跑

mvn -DskipTests=true assembly:assembly
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

[错误]无法执行目标org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:程序内部的程序集(default-cli):读取程序集时出错:找不到程序集描述符. - > [帮助1]

它似乎总是解析插件配置并查找程序集描述符,即使这样,如果我根本没有将插件放入父POM中.谁有解决方案的组装插件?

maven maven-assembly-plugin

2
推荐指数
1
解决办法
3463
查看次数

spark - 线程"main"java.sql.SQLException中的异常:没有合适的驱动程序

已解决:prop.setProperty("driver","oracle.jdbc.driver.OracleDriver")必须将此行添加到连接属性中.

我正试着在当地吃午餐.我用maven创建了一个带依赖关系的jar.

这是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.agildata</groupId>
    <artifactId>spark-rdd-dataframe-dataset</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>

    <properties>    
        <exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
        <spark.version>1.6.0</spark.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>${spark.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.11</artifactId>
            <version>${spark.version}</version>
        </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>12.1.0.2</version>
        </dependency>





    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <!-- get all project dependencies --> …
Run Code Online (Sandbox Code Playgroud)

scala jdbc maven-assembly-plugin apache-spark

2
推荐指数
1
解决办法
6733
查看次数

如何在zip文件中打包多模块?

我有一个多模块项目。每个模块都打包在自己的/ target文件夹中的jar / war文件中。

我想获取每个模块的jar / war文件和一些配置文件,然后将所有内容放入一个zip文件中。

怎么做?我尝试使用Assembly插件,但到目前为止,我所能做的就是将每个模块的zip压缩到各自的/ target文件夹中,因此非常没用^^

maven maven-assembly-plugin

2
推荐指数
1
解决办法
1476
查看次数

标签 统计

maven-assembly-plugin ×10

maven ×9

apache-spark ×1

java ×1

jdbc ×1

scala ×1