You can use profiles:
<profiles>
<profile>
<activation>
<file>
<missing>src/main/webapp/mypath</missing>
</file>
</activation>
... copy ...
</profile>
</profiles>
문제
I have a directory in a dependency, that I want copied in src/main/webapp/mypath during the initialize phase. But I want it to be copied exactly and only once, meaning that:
I tried a couple of approaches with copy-resources and dependency:unpack but maven will always overwrite if mypath coming from the dependency is newer / updated even if I set to false every possible overwrite* configuration I'm aware of.
Any advice or RTFM + link to a manual I didn't read so far?
해결책
You can use profiles:
<profiles>
<profile>
<activation>
<file>
<missing>src/main/webapp/mypath</missing>
</file>
</activation>
... copy ...
</profile>
</profiles>
다른 팁
As described by @William, you can use ant plugin, export the property to maven context and skip the task if "true".
Here is the code:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<available file="src/main/resources/my-data" type="dir"
property="dir-exits"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-zip-dependencies</id>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<skip>${dir-exists}</skip>
<artifactItems>
<artifactItem>
<groupId>com.mygroup</groupId>
<artifactId>myartifactid</artifactId>
<includes>**/*.json</includes> <outputDirectory>src/main/resources/</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>