English 中文(简体)
商品组合——如何复制外部参考资料夹
原标题:maven custom assembly - how to copy external reference folder

I am building a simple Jar project with maven(latest)
When running maven package, I get the jar file at the target directory correctly,
I would like to customize the output so maven will copy some files and dependencies to the target alongside the jar.

目前的组合结构是:

/  
-- resources  
-- src/main/java/com..(project sources)
-- src/main/assembly  (location of the assebmly.xml)

理想的目录结构是:

target
     |
      -- myJar1.0.jar         (the artiface)   
      -- resources            (from the root build folder)
      -- lib                  (all the dependancies)
            |
            -- anotherJar-1.0.jar
            -- anotherJar2-1.0.jar
            -- anotherJar3-1.0.jar


I read custom assembly on apache web site, I added the configuration to maven-assembly-plugin and configured the assembly.xml but I must do something wrong, I dont get the correct output,

页: 1

<assembly>
<id/>
<formats>
    <format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
    <dependencySet>
        <outputDirectory>/lib</outputDirectory>
    </dependencySet>
</dependencySets>
<fileSets>
    <fileSet>
        <directory>target</directory>
        <outputDirectory>/lib</outputDirectory>
        <includes>
            <include>*.jar</include>
        </includes>
    </fileSet>
    <fileSet>
        <directory>resources</directory>
        <outputDirectory>/resources</outputDirectory>
        <includes>
            <include>*.*</include>
        </includes>
    </fileSet>
</fileSets>

The target directory contain the lib with dependencies but it is located in folder with the artifact name, The resources directory is not being copy at all.

Please advise Thank you

最佳回答

通过设计,夜总会粉碎在目标代谢>上产生产出。 这样做是为了避免与其中产生的其他工艺相混淆(< 编码>> 类别:,test-classes等)。

关于未复制的资源,如果你希望复制件的全部内容的话,可以删除<代码><includes>节。 另外,第1条<代码>和t;fileSet>节是多余的。

经过更新的<代码>assembly.xml,将项目艺术品扎根,依靠图书馆的校准和资源,编组者。

<assembly>
<id/>
<formats>
    <format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
    <dependencySet>
        <outputDirectory>/lib</outputDirectory>
        <excludes>
            <exclude>${project.groupId}:${project.artifactId}</exclude>
        </excludes>
    </dependencySet>
    <dependencySet>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>${project.groupId}:${project.artifactId}</include>
        </includes>
    </dependencySet>
</dependencySets>
<fileSets>
    <fileSet>
        <directory>resources</directory>
        <outputDirectory>/resources</outputDirectory>>
    </fileSet>
</fileSets>
问题回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签