我有两个maven项目resources-win
和main-exec
。我尝试从win
的{{1}}文件夹中复制一个dll文件并将其复制到resources-win
,然后我移动到项目编号2 target/classes
,我尝试复制main-exec
中的文件2和src/main/shcemas
的dll文件,并将它们粘贴到项目的目标类中{ {1}}
以下是代码which有助于将文件复制到resources-win
的目标:
resources-win
以下是项目resources-win
的pom.xml的一部分:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources01</id>
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<encoding>UTF-8</encoding>
<resources>
<resource>
<directory>${basedir}/src/main/win</directory>
<includes>
<include>**/*.dll</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
答案 0 :(得分:0)
通过添加到resources-win
的pom.xml使用xsd文件,我确实喜欢这样:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources-xsd</id>
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<encoding>UTF-8</encoding>
<resources>
<resource>
<directory>${basedir}/src/main/schemas</directory>
<includes>
<include>**/*.xsd</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.outputDirectory}/titi.xsd</file>
<type>xsd</type>
<classifier>titi</classifier>
</artifact>
<artifact>
<file>${project.build.outputDirectory}/toto.xsd</file>
<type>xsd</type>
<classifier>toto</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
然后进入main-exec
的pom.xml我添加了:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libraries</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>groupId of resources-win</groupId>
<artifactId>artifactId of resources-win</artifactId>
<version>${resources-win.version}</version>
<type>xsd</type>
<classifier>toto</classifier>
<destFileName>toto.xsd</destFileName>
<outputDirectory>${project.build.directory}/tmp/schemas</outputDirectory>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
我还在main-exec的pom.xml中添加了resources-win的依赖。