ijemmy / maven-replacer-plugin

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

NullPointerException when using inputFilePattern/outputFilePattern #90

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Configure the plugin like this:

<plugin>
    <groupId>com.google.code.maven-replacer-plugin</groupId>
    <artifactId>replacer</artifactId>
    <version>1.5.2</version>
    <executions>
        <execution>
            <phase>prepare-package</phase>
            <goals>
                <goal>replace</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <inputFilePattern>conf/(.+)-template.xml</inputFilePattern>
        <outputFilePattern>conf/$1.xml</outputFilePattern>
        <regex>false</regex>
        <delimiters>
            <delimiter>${"}</delimiter>
        </delimiters>
        <tokenValueMap>conf/test.properties</tokenValueMap>
    </configuration>
</plugin>

2. Put the following files in the conf folder which is located next to the 
pom.xml:

--- test-template.xml ---

<?xml version="1.0" encoding="UTF-8"?>

<test-config>
    <value1>${value1}</value1>
    <value2>${value2}</value2>
</test-config>

--- test.properties ---

value1=replaced value 1
value2=replaced value 2

3. run mvn -e clean install

What is the expected output? What do you see instead?

Expected: A new file test.xml in the conf folder where the variables in 
test-template.xml have been replaced

Found:

[ERROR] Failed to execute goal 
com.google.code.maven-replacer-plugin:replacer:1.5.2:replace (default) on 
project replacer-plugin-test: null: MojoExecutionException: 
NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
com.google.code.maven-replacer-plugin:replacer:1.5.2:replace (default) on 
project replacer-plugin-test: 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:606)
    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:277)
    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

What version of the product are you using?

1.5.2

Original issue reported on code.google.com by wschm...@gmail.com on 22 Jan 2014 at 12:04

GoogleCodeExporter commented 9 years ago
I just found out that I need to specify input files in addition to the patterns.
Add the following line to the config and it works fine:

<filesToInclude>conf/*-template.xml</filesToInclude>

Sorry I didn't check that before reporting a bug...

Still it would be nice if the NPE could be caught and some meaningful error 
message would be presented to the user.

Original comment by wschm...@gmail.com on 22 Jan 2014 at 4:14

GoogleCodeExporter commented 9 years ago
Thanks, I will add a warning message.

Original comment by baker.st...@gmail.com on 19 Feb 2014 at 11:37

GoogleCodeExporter commented 9 years ago

Original comment by baker.st...@gmail.com on 16 Apr 2014 at 9:19