Maven程序集插件未使用目录条目创建tar文件? [英] Maven assembly plugin not creating tar files with directory entries?

查看:72
本文介绍了Maven程序集插件未使用目录条目创建tar文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发我的第一个Maven项目,该项目最终将Java应用程序打包在Debian软件包中(使用jdeb插件).我正在尝试使用Assembly插件来构建tar文件,但是看起来生成的文件并不总是包含目录条目,这将导致dpkg安装失败.

I'm working on my first Maven project which will ultimately package a Java app in a Debian package (using the jdeb plugin). I'm trying to use the assembly plugin to build a tar file, but it looks like the generated file does not always include directory entries, which will cause dpkg install to fail.

以前有人看过吗?

具体来说,生成的tar文件不包含以下目录的条目:

Specifically, the generated tar file does not include directory entries for:

  • 一个指定<includes>的文件集(离开<includes>将导致在tar文件中进入目录条目)
  • dependencySet
  • a fileSet that specifies <includes> (leaving <includes> will result in a directory entry int he tar file)
  • a dependencySet

这是一个不使用<includes>

<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>simple</id>
<formats>
    <format>tar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>

<moduleSets>
</moduleSets>
<fileSets>
    <fileSet>
        <directory>src/main/config</directory>
        <outputDirectory>/etc/${project.artifactId}</outputDirectory>

    </fileSet>
</fileSets>

<dependencySets>

    <dependencySet>
        <outputDirectory>/usr/lib/${project.artifactId}/lib</outputDirectory>
        <scope>runtime</scope>
        <useProjectArtifact>true</useProjectArtifact>
    </dependencySet>

</dependencySets>
<repositories>
</repositories>
<componentDescriptors />
</assembly>

这是tar文件的内容:

Here are the contents of the tar file:

 tar tvf assembly-test-0.0.1-SNAPSHOT-simple.tar
drwxr-xr-x 0/0               0 2012-04-10 12:54 etc/assembly-test/
-rw-r--r-- 0/0               0 2012-04-10 12:52 etc/assembly-test/file1.xml
-rw-r--r-- 0/0               0 2012-04-10 12:52 etc/assembly-test/file2.xml
-rw-r--r-- 0/0            2131 2012-04-10 13:26 usr/lib/assembly-test/lib/assembly-test-0.0.1-SNAPSHOT.jar

现在,如果我使用带有某些包含模式的程序集:

Now if I use an assembly with some include patterns:

<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>include-match</id>
<formats>
    <format>tar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>

<moduleSets>
</moduleSets>
<fileSets>
    <fileSet>
        <directory>src/main/config</directory>
        <outputDirectory>/etc/${project.artifactId}</outputDirectory>
        <includes>
            <include>*.xml</include>
        </includes>
    </fileSet>
</fileSets>

<dependencySets>

    <dependencySet>
        <outputDirectory>/usr/lib/${project.artifactId}/lib</outputDirectory>
        <scope>runtime</scope>
        <useProjectArtifact>true</useProjectArtifact>
    </dependencySet>

</dependencySets>
<repositories>
</repositories>
<componentDescriptors />
</assembly>

tar文件的内容丢失了目录条目:

The contents of the tar file loses the directory entry:

tar tvf assembly-test-0.0.1-SNAPSHOT-include-match.tar
-rw-r--r-- 0/0               0 2012-04-10 12:52 etc/assembly-test/file1.xml
-rw-r--r-- 0/0               0 2012-04-10 12:52 etc/assembly-test/file2.xml
-rw-r--r-- 0/0            2131 2012-04-10 13:26 usr/lib/assembly-test/lib/assembly-test-0.0.1-SNAPSHOT.jar

这似乎是程序集插件中的错误,尽管我仍在尝试中.我当然可以解决它(使用软件包中的preinst脚本,也许为jdeb构建目录结构以供构建),但是我希望在描述符文件中保留尽可能多的内容.

This seems like a bug in the assembly plugin, though I'm still experimenting with it. I can certainly work around it (use a preinst script in the package, maybe build out a directory structure for jdeb to build from), but I'd love to keep as much as possible in the descriptor file.

推荐答案

有一种解决此问题的简单方法,只需包含所需的目录,如果需要所有目录,则只需包含"**/"即可,例如:

There's a simple way to work around this, simply include the directories you want or "**/" if you want all of them, so for example:

<include>mydir/**/</include>

请注意结尾的/,因为这是拉目录的内容.我认为当前的行为可能是故意的,因为include似乎恰好引入了您所包含的内容,而没有其他内容.顺便说一句,尽管最终的tarball不能满足npm的要求,所以maven的支持似乎还是有点可疑.

Note the trailing / as that's the thing that pulls in the directory. I think the current behaviour is probably intentional, since include appears to pull in precisely what you include and nothing else. As an aside though the resulting tarball does not satisfy npm, so maven's support still seems a little suspect.

这篇关于Maven程序集插件未使用目录条目创建tar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆