java - 如何创建一个包含 shell 脚本和不在 jar 中的属性文件的 maven 程序集?

我正在尝试使用 Maven 构建一个独立的应用程序

使用描述的程序集插件 How do you create a standalone application with dependencies intact using Maven?

这将创建小部件分发 zip 包含

widget-1.0
widget-1.0/lib/widget.jar
widget-1.0/lib/3rdpartyjar1.jar
widget-1.0/lib/3rdpartyjar2.jar

...

但在我的 src 树中我有:

src/main/bin/widget.sh 

这并没有进入最终的发行版 zip,我希望它放在这里

widget-1.0/widget.sh

在我的 src 树中,我还有一个属性文件

src/main/properties/widget.properties

目前正在进入

widget-1.0/lib/widget.jar

但因为我希望它是可编辑的,所以我希望它在

widget-1.0/widget.properties

是否可以在 maven 中做到这一点?

编辑 使用博客中的信息如下:

  1. 将 bin 文件夹重命名为 scripts 文件夹,因为这是标准 Maven 名称
  2. 将 widget.properties 移到脚本文件夹中
  3. 修改了我的 assembly.xml 以包含一个文件集

这是新的 xml

<?xml version="1.0" encoding="UTF-8"?>
<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>distribution</id>
    <formats>
        <format>zip</format>
    </formats>
    <dependencySets>
        <dependencySet>
            <scope>runtime</scope>
            <outputDirectory>lib</outputDirectory>
            <unpack>false</unpack>
        </dependencySet>
    </dependencySets>
    <fileSets>
        <fileSet>
            <directory>${project.build.scriptSourceDirectory}</directory>
            <outputDirectory></outputDirectory>
            <includes>
                <include>widget.sh</include>
                <include>widget.properties</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

但是小问题但无法在任何地方找到 maven 标准文件夹变量的列表,即属性文件夹是否有 ${project.build.scriptSourceDirectory} 的等价物

最佳答案

我找到了 this blog post成为如何做到这一点的好教程。

另外,我认为您放置文件的文件夹的名称是相关的。 Maven 显然对 src/main/java 中的文件和 src/main/resources 中的文件做不同的事情。我不是 100% 确定,但这个文件夹的名称可能意味着文件是否在 jar 中结束。

Here是 Maven 目录名称属性的列表。

https://stackoverflow.com/questions/11631682/

相关文章:

xcode - 在 Xcode 中指定子项目的配置

android - 特拉维斯-CI `Android 28 licenses have not be

build - 如何使用 NUnit.Runners 包和 psake 执行 NUnit 测试?

c++ - 使用 CMake、Clang 和 Ninja 在 Windows 上构建 c++ 项目

c++ - 如何将 CMake 项目与基于 GYP 的库集成

maven - 如何从 lib 文件夹中添加 Maven 依赖 jar 文件

build - Dojo 1.8 和构建(或缺少)

java - eclipse 不编译项目

build-process - 特定于目标的变量作为 Makefile 中的先决条件

c++ - 在 Android NDK 项目中使用我自己的预构建共享库