ijemmy / maven-replacer-plugin

Automatically exported from code.google.com/p/maven-replacer-plugin
MIT License
0 stars 0 forks source link

Improve Documentation for multiple executions #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I used the replacer plugin in multiple projects and had the issue to use it for 
multiple files in different folders and different destination folders.
I used various maven plugins before but was not aware of the fact that a 
configuration can be set "globally" for a plugin AND for a specific execution. 
Therefore i started to make various workarounds to move the file form folder A  
to B and so on...much pain...

Now all I'm asking about is if you could add an example to the UsageGuide in 
which the configuration is set for a more than one execution with a specific 
configuration. This could probably save time for many developers  as I am which 
are not so aware of the power of maven plugins  :)

Here a suggestion:
<executions>
    <execution>
        <id>execution1</id>
        <phase>prepare-package</phase>
        <goals>
            <goal>replace</goal>
        </goals>
        <configuration>
            <file>template/somefile1.txt</file>
            <outputFile>target/somefile1.txt</outputFile>
            <replacements>
                <replacement>
                    <token>TOKEN1</token>
                    <value>VALUE1</value>
                </replacement>
            </replacements>
        </configuration>
    </execution>
    <execution>
        <id>execution2</id>
        <phase>prepare-package</phase>
        <goals>
            <goal>replace</goal>
        </goals>
        <configuration>
            <file>template/somefile2.txt</file>
            <outputFile>target/somefile2.txt</outputFile>
            <replacements>
                <replacement>
                    <token>TOKEN2</token>
                    <value>VALUE2</value>
                </replacement>
            </replacements>
        </configuration>
    </execution>
</executions>

Cheers
Raphi

Original issue reported on code.google.com by mister.n...@gmail.com on 7 Mar 2013 at 11:18

GoogleCodeExporter commented 9 years ago
I'll have a think about this one since this is standard maven functionality.

Original comment by baker.st...@gmail.com on 15 Mar 2013 at 12:50

GoogleCodeExporter commented 9 years ago
I am just going to delete this. This is standard maven behaviour.

Original comment by baker.st...@gmail.com on 22 Apr 2013 at 1:38

GoogleCodeExporter commented 9 years ago
I'd like to suggest at least that the examples you provide put the 
`configuration` block inside the relevant `execution` block.  Agree with you it 
is standard maven behaviour -- but also with OP doing otherwise just encourages 
mistakes when they try to run two different set of replacements!

Original comment by alex.hen...@cloudsoftcorp.com on 25 Sep 2013 at 4:36

GoogleCodeExporter commented 9 years ago
but it doesn't work, it keeps throwing below error if I try to have more than 
one execution

[ERROR] Failed to execute goal 
com.google.code.maven-replacer-plugin:replacer:1.5.2:replace (default-cli) on 
project csb
-web: null: MojoExecutionException: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
com.google.code.maven-replacer-plugin:rep
lacer:1.5.2:replace (default-cli) on project csb-web: null
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException
        at com.google.code.maven_replacer_plugin.ReplacerMojo.execute(ReplacerMojo.java:389)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
Caused by: java.lang.NullPointerException
        at java.io.File.<init>(File.java:251)
        at com.google.code.maven_replacer_plugin.file.FileUtils.isAbsolutePath(FileUtils.java:63)
        at com.google.code.maven_replacer_plugin.OutputFilenameBuilder.buildOutputFile(OutputFilenameBuilder.java:25)
        at com.google.code.maven_replacer_plugin.OutputFilenameBuilder.buildFrom(OutputFilenameBuilder.java:16)
        at com.google.code.maven_replacer_plugin.ReplacerMojo.replaceContents(ReplacerMojo.java:432)
        at com.google.code.maven_replacer_plugin.ReplacerMojo.execute(ReplacerMojo.java:379)
        ... 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Original comment by CSBTest...@gmail.com on 7 Nov 2013 at 10:28

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I get the same error. While this should be standard maven behaviour, it is not 
working for this plugin. I just can't make it to do different replacements for 
different files...

Original comment by tot...@gmail.com on 4 Apr 2014 at 7:04

GoogleCodeExporter commented 9 years ago
Ok, should've been digging first, and write later.
I found out from another issue, that the above is possible, but than you need 
to invoke maven with the phase, and not with the goal. Then you won't get this 
NPE error.

Original comment by tot...@gmail.com on 4 Apr 2014 at 7:14