antibrumm / copy-maven-plugin Goto Github PK
View Code? Open in Web Editor NEWMaven plugin for file copy / move and replacing content
Maven plugin for file copy / move and replacing content
I get the following log:
"
[INFO] --- copy-maven-plugin:0.0.1:copy (copy) @ skp-foundation ---
[INFO] Resource:
WorkingDir: D:\dev\LR\skp\workspace\skp-foundation\target
Paths:
D:\dev\LR\skp\workspace\skp-foundation\target -> D:\dev\LR\skp\liferay-portal-6.2-ee-sp10\deploy\tomcat-7.0.42\lib\ext
Replaces:
[INFO]
The Paths output is correct but the last output lines starting with - and + is incorrect. The destination folder is not correctly set.
Here is also my configuration:
<plugin>
<groupId>ch.mfrey.maven.plugin</groupId>
<artifactId>copy-maven-plugin</artifactId>
<version>0.0.1</version>
<executions>
<execution>
<id>copy</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<showfiles>true</showfiles>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<move>true</move>
<includes>
<include>*.jar</include>
</includes>
<paths>
<path>
<from>${project.build.directory}</from>
<to>${liferay.app.server.lib.global.dir}</to>
</path>
</paths>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
After upgrading maven from 3.8.x to 3.9.1, the following build error occurs:
[ERROR] Failed to execute goal ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy (copy-youtube-video-player-images-for-war) on project my-project: Execution copy-youtube-video-player-images-for-war of goal ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy failed: A required class was missing while executing ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy: org/codehaus/plexus/util/FileUtils
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/v:/maven/.m2/repository/ch/mfrey/maven/plugin/copy-maven-plugin/1.0.0/copy-maven-plugin-1.0.0.jar
[ERROR] urls[1] = file:/v:/maven/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
[ERROR] Number of foreign imports: 1
A workaround is to add org.codehaus.plexus:plexus-utils:3.5.0 artifact as dependency of the plugin ch.mfrey.maven.plugin:copy-maven-plugin as follows:
<plugin>
<groupId>ch.mfrey.maven.plugin</groupId>
<artifactId>copy-maven-plugin</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>
</plugin>
Overwriting files should be possible by switching a flag to true. (defaults to false)
I had to add the plexus utils dependency in a POM that uses copy-maven-plugin
Before I got
[ERROR] Failed to execute goal ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy (autodeploy-expath-pkgs-for-appassembler) on project exist-distribution: Execution autodeploy-expath-pkgs-for-appassembler of goal ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy failed: A required class was missing while executing ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy: org/codehaus/plexus/util/FileUtils
Adding
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.1</version>
</dependency>
Did solve the issue.
I do wonder which version of plexus-utils would be optimal and also why this dependency is not declared.
Thanks for the great Maven plugin! I have a small issue though. If I have something like this as a replacement:
<replace>
<from>some_text</from>
<to>${some.var}</to>
</replace>
And if then some.var
is empty, I get the following error during execution:
15:14:50 [ERROR] Failed to execute goal ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy (some-execution-id) on project some.proj.name: Execution some-execution-id of goal ch.mfrey.maven.plugin:copy-maven-plugin:1.0.0:copy failed: Cannot invoke "java.lang.CharSequence.toString()" because "replacement" is null -> [Help 1]
The longer stack trace is:
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.toString()" because "replacement" is null
java.lang.String.replace (String.java:2961)
ch.mfrey.maven.plugin.copy.CopyMojo.copyFile (CopyMojo.java:76)
ch.mfrey.maven.plugin.copy.CopyMojo.execute (CopyMojo.java:126)
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
...
The crash happens here. The 2nd argument to String.replace
is null
. It appears that Maven provides null
for empty to
rather than an empty string.
It would be great to be able to replace by an empty string. I think it would be easy to fix: just check for null
, and use an empty string instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.