简体   繁体   中英

How to use DukeScript with Eclipse?

Is there any tutorial for using DukeScript with Eclipse? I can find only a description for using with NetBeans.

Now I've spent a few hours trying to run a Dukescript project. Not being a NetBeans user, I generated a project from the Maven archetype and then I tried to import it into Eclipse. One problem is that m2eclipse gets confused by the html4j-maven-plugin, it doesn't know in which phase of the build lifecycle it has to run (as far as I understand). So I've added this:

  <pluginManagement>
<plugins>
  <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
  <plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
        <lifecycleMappingMetadata>
            <pluginExecutions>
                <pluginExecution>
                    <pluginExecutionFilter>
                        <groupId>org.netbeans.html</groupId>
                        <artifactId>
                            html4j-maven-plugin
                        </artifactId>
                        <versionRange>[1.1,)</versionRange>
                        <goals>
                            <goal>process-js-annotations</goal>
                        </goals>
                    </pluginExecutionFilter>
                    <action>
                        <execute></execute>
                    </action>
                </pluginExecution>
            </pluginExecutions>
        </lifecycleMappingMetadata>
    </configuration>
  </plugin>
</plugins>

Now m2eclipse doesn't compain. Still, Eclipse doesn't find the Data (model) classes that the plugin generates. So I simply added /target/generated-sources/annotations to the source folder. Perhaps not the most elegant solution, there must a way of doing it in the pom. So, there are no compilation errors. Yet, when I run it I get an exception:

Exception in thread "main" java.util.ServiceConfigurationError: org.netbeans.html.boot.spi.Fn$Presenter: Provider org.netbeans.html.boot.fx.FXPresenter could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:224)
at java.util.ServiceLoader.access$100(ServiceLoader.java:181)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:377)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at net.java.html.boot.BrowserBuilder.showAndWait(BrowserBuilder.java:275)
at javelin.Main.main(Main.java:14)
Caused by: java.lang.UnsupportedClassVersionError: javafx/application/Platform : Unsupported major.minor version 52.0

It looks perhaps like a mismatch between target bytecode and runtime. I'll update this answer if I figure it out.

Update

Success! I've set java compile source and target to 8

      <configuration>
          <source>1.8</source>
          <target>1.8</target>
      </configuration>

And also for the java runtime in .project

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

There was one last thing to do and it was setting the "browser.rootdir" property so that the app could find the web resources. Just for testing:

String userdir = System.getProperty("user.dir") + "/src/main/webapp";
System.setProperty("browser.rootdir", userdir ); 

I can open the page now and start the animation but I can't stop it due to other errors. Anyway, it's a start.

Update 2

I've managed to get Eclipse to process DukeScript annotations and generate sources using this plugin: m2e-apt . There's one more thing to add to the pom for the plugin to work:

<plugin>   
   <groupId>org.bsc.maven</groupId>   
      <artifactId>maven-processor-plugin</artifactId>   
      <version>2.2.4</version>   
      <executions>   
         <execution>   
           <id>process</id>   
             <goals>   
               <goal>process</goal>   
             </goals>   
             <configuration>
                <outputDirectory>target/generated-sources/annotations</outputDirectory>
            </configuration> 
          </execution>   
        </executions>   
        <dependencies>   
          <dependency>
            <groupId>org.netbeans.html</groupId>
            <artifactId>html4j-maven-plugin</artifactId>
            <version>${net.java.html.version}</version>
          </dependency>
         </dependencies>   
</plugin> 

These issues are similar to those raised during usability review . The way to work around such compilation errors is to switch to command line and do "mvn clean install" that works properly. Configuring Eclipse is possible to some extend and you seem to have found the right way.

Update: I wrote a short tutorial . Please let me know if it works for you, and what needs to be improved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM