【问题标题】:Maven assembly : including a file at the same level of baseDirectoryMaven 程序集:包含一个与 baseDirectory 同级的文件
【发布时间】:2013-01-13 09:08:39
【问题描述】:

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

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

killer-app-archive.zip
 \- killer-app
    \- whatever ...

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

killer-app-archive.zip
 \- killer-app
 |  \- whatever ...
 \- launch.bat

我一直在尝试玩游戏

但这只是删除/killer-app/ 文件夹,我必须保留它。

【问题讨论】:

    标签: maven maven-assembly-plugin


    【解决方案1】:

    三个步骤可以解决您的问题:

    • baseDirectory 更改为../
    • 使用FileSets 添加额外文件。
    • 使用DependencySet 添加项目工件(useProjectArtifact = true)

    这应该可以解决您的问题。这是一个例子:

    <?xml version="1.0" encoding="UTF-8"?>
    <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>my-assembly</id>
        <baseDirectory>../</baseDirectory>
        <formats>
            <format>zip</format>
        </formats>
        <includeBaseDirectory>false</includeBaseDirectory>
        <dependencySets>
            <dependencySet>
                <unpack>true</unpack>
                <useProjectArtifact>true</useProjectArtifact>
            </dependencySet>
        </dependencySets>
        <fileSets>
            <fileSet>
                <directory>path/to/resource</directory>
                <includes>
                    <include>**/*.bat</include>
                </includes>
                <outputDirectory>/</outputDirectory>
            </fileSet>
        </fileSets>
    </assembly>
    

    【讨论】:

    • 抱歉,文件集包含在 /killer-app/ 文件夹中,而不是在父级。我在 outputdirectory 中尝试了 ../ 但这不起作用。
    • 如何将 baseDirectory 设置为 '../'?
    猜你喜欢
    • 1970-01-01
    • 2015-02-12
    • 1970-01-01
    • 2017-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-19
    相关资源
    最近更新 更多