Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 向Maven工件添加内容文件_Java_Maven - Fatal编程技术网

Java 向Maven工件添加内容文件

Java 向Maven工件添加内容文件,java,maven,Java,Maven,我用maven创建了一个工件,我想在jar文件旁边向目标消费者添加一些内容文件。(我想添加一些Jenkins脚本,但我想在消费者升级到较新版本的工件时更新这些脚本)。 这类似于.NETNuget,您可以在其中向consumer项目添加内容库 根据@tashkhhisi的建议,我正在尝试Maven汇编插件 项目结构: > pipline (folder) >>> file1.groovy (file) >>> file2.groovy (file) >

我用maven创建了一个工件,我想在
jar
文件旁边向目标消费者添加一些内容文件。(我想添加一些Jenkins脚本,但我想在消费者升级到较新版本的工件时更新这些脚本)。
这类似于.NETNuget,您可以在其中向consumer项目添加内容库

根据@tashkhhisi的建议,我正在尝试
Maven汇编插件

项目结构:

> pipline (folder)
>>> file1.groovy (file)
>>> file2.groovy (file)
>>> file3.groovy (file)
> src (folder)
>>> ...
> assembly (folder)
>>> distribution.xml (file)
> pom (file)
在pom文件中:

...
 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly/distribution.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>trigger-assembly</id>
                        <phase>package</phase>
                        <goals>
                           <goal>single</goal>
                       </goals>
                    </execution>
                </executions>
            </plugin>
    </build>                     
我可以在目标文件夹中看到创建了两个
jar
文件:

target/myLib-1.1.0-SNAPSHOT.jar
target/myLib-1.1.0-SNAPSHOT-distribution.jar

但是当我试图从另一个项目中使用它时,没有创建带有groovy文件的
管道
文件夹…

在您的配置中,您说管道在
src
旁边,而在pom.xml中,您将outputDirectory定义为
${basedir}/pipeline
,它正好在
src
旁边(管道已经存在!)因此,如果要将此管道目录放在
target
目录中的目标jar文件旁边,则应将此配置修改为类似以下内容:

${basedir}/target/pipeline

通过使用assembly plugin创建包含部署中所需全部内容的zip文件是更好的方法,请阅读以下链接:

这是不可能的

将某些内容添加为依赖项不会在项目中添加或创建任何文件夹


使用者需要向项目添加逻辑,以从依赖项中提取文件并将其复制到正确的位置(可能使用Maven依赖项插件).

目录是相对于pom.xml的folder@user7294900它们处于同一级别…您是否添加了
maven资源插件
工件?我希望在工件的使用者处使用这些文件创建一个包含内容的文件夹。而不是jar中的文件。这看起来很有希望。我会调查,如果可以,我会接受answer@Yaron我刚刚试着用资源插件来做这件事,经过一些修改后效果也不错。我编辑了我的答案,请再读一遍。嗨@Tashkhhisi,我用maven assembly插件更新了这个问题。仍然有些东西不起作用……让我们明确一点:你想要一个zipfile,其中包含你的目标jar文件和管道文件夹及其内容?是的。我真的不在乎它是不是一个zip。我想让消费者获得jar文件依赖项和管道文件夹h其中的内容(我排除了其中一个文件,但基本上就是这个想法):-)。只是为了确定,我需要消费者获取依赖关系树,这样jar就能够正常工作。。。
target/myLib-1.1.0-SNAPSHOT.jar
target/myLib-1.1.0-SNAPSHOT-distribution.jar