客户端可交付的部分内容包括我们正在处理的项目的源代码。我在mvn generate-sources中使用maven。问题是它包含了所有的依赖项,并聚合了每个依赖项的源。我正在尝试生成一个平面结构,并在.java上过滤groupid文件。
有关maven源插件的文档非常回避。我所做的所有搜索都指向了过滤资源,这不是我想要的。
我的项目结构是一个带孩子的父级pom,我正试图实现这样的目标:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<resouces>
<filter>
<include>com.mygroupid.project</include>
</filter>
</resouces>
</plugin>我期待的是:
编辑:
假设这样的结构:
- module-1 pom.xml // aggregate project
|- module-1-core (has dependency to module-2 and module-2)
|- module-1-war
- module-2 pom.xml // aggregate project
|- module-2-commons
- module-3 pom.xml // aggregate project
|- module-3-services
- // etc...我希望档案如下:
- big-fat-code-sources.zip
|- module-1-core sources + test source
|- module-1-war sources + test source
|- module-2-commons sources + test source
|- module-3-services sources + test source
|- // etc...发布于 2018-03-29 14:05:55
最后,我用maven-assembly-plugin解决了这个问题,还有很多不太明显的额外配置。
在我的assembly.xml描述符中,我在项目的模块上添加了一个过滤器:
<moduleSets> // 1
<moduleSet>
<includes>
<include>mrkrabs-secret-recipe:*</include>
</includes>
<useAllReactorProjects>true</useAllReactorProjects>
<sources>
<outputDirectoryMapping>${artifactId}-${version}</outputDirectoryMapping> // 2
<includeModuleDirectory>true</includeModuleDirectory>
<fileSets>
<fileSet> // 3
<directory>src</directory>
<excludes>
<exclude>**/target/**</exclude>
<exclude>**/bin/**</exclude>
</excludes>
</fileSet>
</fileSets>
</sources>
</moduleSet>
</moduleSets>这还不包括传递依赖项及其源代码。
因此我在依赖项上添加了一个筛选器:
<dependencySets> // 1
<dependencySet>
<includes> // 2
<include>mrkrabs-secret-recipe:*</include>
</includes>
<scope>provided</scope>
<outputDirectory>/dependencies</outputDirectory> // 3
<useTransitiveFiltering>true</useTransitiveFiltering> // 4
<unpack>true</unpack>
<unpackOptions> // 5
<includes>
<include>mrkrabs-*/**</include>
</includes>
<excludes>
<exclude>*.sql</exclude>
<exclude>*.zip</exclude>
<exclude>*.class</exclude>
<exclude>*.jar</exclude>
</excludes>
<useDefaultExcludes>true</useDefaultExcludes>
</unpackOptions>
</dependencySet>
</dependencySets>1. Include only mrkrabs projects (the `useTransitiveFiltering` should take care of this but does not)
2. Exclude certain files we do not wanna see in the archive (.sql, .zip, .class, .jar)
发布于 2018-03-16 16:33:07
使用source:aggregate目标可以解决此任务:
mvn clean source:aggregate假设您有以下项目结构
- root pom.xml // aggregate project
|- module1 // jar module
|- module2 // another jar...使用根pom中的以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
</plugin>执行上述命令时,它将在target文件夹中生成一个target,该文件夹将包含混合在一起的所有modules源。
这个Maven目标的更多医生。
https://stackoverflow.com/questions/49323642
复制相似问题