我有一个用例,我需要使用maven-buildHelper插件将文件夹target / schemas包含为源文件夹。我正在为这个项目制造一场战争。创建源jar时,目标/模式的内容也存在于其中。我不想将目标/模式的内容添加到我的源jar中。如何实现?
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>***************</groupId>
<artifactId>core</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>identity</artifactId>
<packaging>war</packaging>
<dependencies>
...............
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>identity</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>***************</groupId>
<artifactId>authentication-service</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
<type>jar</type>
<outputDirectory>${project.build.directory}/schemas</outputDirectory>
<includes>**/*.java,**/*.xml</includes>
</artifactItem>
<artifactItem>
<groupId>***************</groupId>
<artifactId>authorization-service</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
<type>jar</type>
<outputDirectory>${project.build.directory}/schemas</outputDirectory>
<includes>**/*.java,**/*.xml</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${maven.plugin.buildHelper}</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/schemas</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${maven.plugin.jaxb2}</version>
<executions>
<execution>
<id>schemagen-combined</id>
<goals>
<goal>schemagen</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<includes>
<include>***************/core/identity/domain/*.java</include>
<include>***************/authentication/domain/*.java</include>
<include>***************/authorization/domain/*.java</include>
</includes>
<outputDirectory>${project.build.directory}/schemas</outputDirectory>
<generateDirectory>${project.build.directory}/generated-sources</generateDirectory>
</configuration>
</execution>
</executions>
</plugin
</plugins>
我有一个Web项目标识,它取决于两个jar身份验证和授权。在项目标识中,我使用jaxb2-maven-plugin为身份验证,授权和身份源生成xsd。作为插件jaxb2-maven-plugin,仅适用于maven源路径中存在的源,我在文件夹目标/架构中下载用于身份验证和授权的源,将此文件夹目标/架构添加为maven源文件夹,然后运行jaxb2 -maven-plugin生成xsd。现在,当我为身份构建源jar时,它还包括我不想要的身份验证和授权来源。