Devskiller / jpa2ddl

JPA Schema Generator Plugin
Apache License 2.0
110 stars 33 forks source link

Path resolution on MS Windows results in invalid path #11

Closed marrem closed 6 years ago

marrem commented 6 years ago

Steps to reproduce:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.devskiller.jpa2ddl:jpa2ddl-maven-plugin:0.9.5:generate (default-cli) on project core: Illegal char <:> at index 2: /C:/Users/remijn/Documents/NetBeansProjects/localdna/core/src/main/java/nl%5cminvenj%5cnfi%5clocaldna%5ccore%5cmodel
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    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:993)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Illegal char <:> at index 2: /C:/Users/remijn/Documents/NetBeansProjects/localdna/core/src/main/java/nl%5cminvenj%5cnfi%5clocaldna%5ccore%5cmodel
    at com.devskiller.jpa2ddl.GenerateMojo.execute(GenerateMojo.java:111)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Users/remijn/Documents/NetBeansProjects/localdna/core/src/main/java/nl%5cminvenj%5cnfi%5clocaldna%5ccore%5cmodel
    at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
    at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
    at java.nio.file.Paths.get(Paths.java:84)
    at com.devskiller.jpa2ddl.FileResolver.listClassNamesInPackage(FileResolver.java:76)
    at com.devskiller.jpa2ddl.SchemaGenerator.generate(SchemaGenerator.java:52)
    at com.devskiller.jpa2ddl.GenerateMojo.execute(GenerateMojo.java:108)
    ... 22 more

Maven plugin config:

            <plugin>
                <groupId>com.devskiller.jpa2ddl</groupId>
                <artifactId>jpa2ddl-maven-plugin</artifactId>
                <version>0.9.5</version>
                <configuration>
                    <outputPath>${basedir}/src/main/resources/database.sql</outputPath>
                    <packages>
                        <package>nl.minvenj.nfi.localdna.core.model</package>
                    </packages>
                    <jpaProperties>
                        <property>
                            <name>hibernate.dialect</name>
                            <value>org.hibernate.dialect.MySQL57Dialect</value>
                        </property>
                        <property>
                            <name>hibernate.default_schema</name>
                            <value>prod</value>
                        </property>
                    </jpaProperties>
                    <formatOutput>true</formatOutput>
                    <skipSequences>true</skipSequences>
                    <delimiter>;</delimiter>
                    <action>DROP_AND_CREATE</action>
                </configuration>
            </plugin>   

Looks like uRL.getPath is the culprit, this:

public class App {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        String packageName = "org.example.model";
        Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(packageName.replace('.', File.separatorChar));

        while (resources.hasMoreElements()) {
            URL uri = resources.nextElement();
            System.out.println(uri);
            System.out.println(uri.getPath());
        }

    }

}

Produces:

file:/C:/Users/remijn/Documents/NetBeansProjects/resolve-source-files/target/classes/org%5cexample%5cmodel
/C:/Users/remijn/Documents/NetBeansProjects/resolve-source-files/target/classes/org%5cexample%5cmodel

The url is valid, the path is not.

marrem commented 6 years ago

Thanks

Marc

Verstuurd vanaf mijn iPhone

Op 17 nov. 2017 om 23:52 heeft Jakub Kubryński notifications@github.com het volgende geschreven:

Closed #11 via 632155e.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jkubrynski commented 6 years ago

It's released in 0.9.7

marrem commented 6 years ago

Nice!