random-maven / flatten-maven-plugin

Simplify maven project descriptor for artifact deployment
https://random-maven.github.io/flatten-maven-plugin/flatten-mojo.html
Other
9 stars 5 forks source link

mysterious encoding during dependency:resolve #5

Closed m50d closed 6 years ago

m50d commented 6 years ago

"scope" value somehow corrupted leading to invalid XML output when using maven-dependency-plugin 3.0.2

See https://github.com/random-maven/scalor-maven-plugin/issues/16 - in particular my last comment poking around with JDB.

Minimal pom to reproduce:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.carrotgarden.maven</groupId>
    <artifactId>scalor-maven-plugin</artifactId>
    <version>0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <dependencies>
        <dependency>
            <groupId>com.github.klieber</groupId>
            <artifactId>phantomjs-maven-plugin</artifactId>
            <version>0.7</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.0.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.carrotgarden.maven</groupId>
                <artifactId>flatten-maven-plugin</artifactId>
                <version>1.3.20180210195103</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>flatten</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Running mvn install with this pom outputs:

C:\Users\md401\eclipse-workspace\scalor-maven-plugin>mvn install
[INFO] Arkon: provisioning...
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building scalor-maven-plugin 0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- flatten-maven-plugin:1.3.20180210195103:flatten (default) @ scalor-maven-plugin ---
[INFO] Resolving dependencies.
[INFO] Removing pom.xml model members.
[ERROR] C:\Users\md401\eclipse-workspace\scalor-maven-plugin\pom.xml [1:1]: Flatten failure
java.lang.IllegalStateException: character 27 is not allowed in output
    at org.codehaus.plexus.util.xml.pull.MXSerializer.writeElementContent (MXSerializer.java:1191)
    at org.codehaus.plexus.util.xml.pull.MXSerializer.text (MXSerializer.java:958)
    at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writeDependency (MavenXpp3Writer.java:572)
    at org.apache.maven.model.io.xpp3.MavenXpp3Writer.writeModel (MavenXpp3Writer.java:1108)
    at org.apache.maven.model.io.xpp3.MavenXpp3Writer.write (MavenXpp3Writer.java:115)
    at com.carrotgarden.maven.flatten.FlattenMojo.writePom (FlattenMojo.java:210)
    at com.carrotgarden.maven.flatten.FlattenMojo.persistModel (FlattenMojo.java:374)
    at com.carrotgarden.maven.flatten.FlattenMojo.execute (FlattenMojo.java:466)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.421 s
[INFO] Finished at: 2018-03-31T14:21:07+01:00
[INFO] Final Memory: 21M/70M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.carrotgarden.maven:flatten-maven-plugin:1.3.20180210195103:flatten (default) on project scalor-maven-plugin: Flatten failure: character 27 is not allowed in output -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoFailureException

Changing the version of maven-dependency-plugin (even to 3.0.1) makes the problem go away.

Andrei-Pozolotin commented 6 years ago
  1. still can not reproduce https://github.com/random-maven/flatten-maven-plugin/tree/master/src/it/issue-5

  2. nonetheless, changed:

  3. please try to reproduce problem with 1.4.x https://bintray.com/random-maven/maven/flatten-maven-plugin

  4. after that, please verify if parent issue is resolved https://github.com/random-maven/scalor-maven-plugin/issues/16

m50d commented 6 years ago

Issue is not present in 1.4.20180401224951. I was using Java 9 so those changes could be related.

Andrei-Pozolotin commented 6 years ago

resolved https://github.com/random-maven/flatten-maven-plugin/releases/tag/1.4.20180402132337