wocommunity / wolips

wolips
53 stars 53 forks source link

Imported maven projects fail to launch #165

Closed nullterminated closed 2 years ago

nullterminated commented 2 years ago

When importing a maven project, right clicking on the Application.java and running/debugging as WOApplication fails because of

java.lang.NullPointerException: Cannot invoke "org.objectstyle.wolips.core.resources.types.project.ProjectAdapter.getWorkingDirFolder()" because "projectAdaptor" is null
    at org.objectstyle.wolips.launching.delegates.WOJavaLocalApplicationLaunchConfigurationDelegate.verifyWorkingDirectory(WOJavaLocalApplicationLaunchConfigurationDelegate.java:179)
    at org.eclipse.jdt.launching.JavaLaunchDelegate.getVMRunnerConfiguration(JavaLaunchDelegate.java:77)
    at org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:160)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:803)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:716)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1021)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:1224)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)   

This is due to the fact that in the .project file, the wolips nature and buildspec are missing. If I modify the .project file to look something like,

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>wodocker</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.objectstyle.wolips.incrementalbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
        <nature>org.objectstyle.wolips.incrementalapplicationnature</nature>
    </natures>
</projectDescription>

Then the project will launch. It would be nice if I didn't have to manually edit this file to make it work.

nullterminated commented 2 years ago

I should add that on frameworks, the proper nature is org.objectstyle.wolips.incrementalframeworknature and applications it is org.objectstyle.wolips.incrementalapplicationnature seen above.

hprange commented 2 years ago

The latest version of the Maven archetypes adds the WOLips nature by default when creating a new project. Anyway, since many people don't like adding Eclipse configuration files to the source code repository, it would be great if:

nullterminated commented 2 years ago

I came to a similar conclusion after sleeping on it :) I think if the error message is informative, that's probably enough for me. I'll see about adding one.

nullterminated commented 2 years ago

Added IllegalStateException and error message pointing to this page when projectAdapter is null.