4

有没有在 Eclipse 中使用DukeScript的教程?我只能找到与 NetBeans 一起使用的说明。

4

3 回答 3

1

现在我花了几个小时试图运行一个 Dukescript 项目。我不是 NetBeans 用户,而是从 Maven 原型生成了一个项目,然后尝试将其导入 Eclipse。一个问题是 m2eclipse 被 html4j-maven-plugin 弄糊涂了,它不知道它必须在构建生命周期的哪个阶段运行(据我所知)。所以我添加了这个:

  <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>

现在 m2eclipse 不兼容。尽管如此,Eclipse 仍然找不到插件生成的数据(模型)类。所以我只是将 /target/generated-sources/annotations 添加到源文件夹中。也许不是最优雅的解决方案,在 pom.xml 中必须有办法做到这一点。因此,没有编译错误。然而,当我运行它时,我得到了一个例外:

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

它看起来可能像目标字节码和运行时之间的不匹配。如果我弄清楚了,我会更新这个答案。

更新

成功!我已将 java 编译源和目标设置为 8

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

也适用于 .project 中的 java 运行时

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

还有最后一件事要做,它是设置“browser.rootdir”属性,以便应用程序可以找到 Web 资源。仅用于测试:

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

我现在可以打开页面并启动动画,但由于其他错误我无法停止它。无论如何,这是一个开始。

更新 2

我已经设法让 Eclipse 处理 DukeScript 注释并使用这个插件生成源:m2e-apt。为了使插件正常工作,还有一件事要添加到 pom 中:

<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> 
于 2015-05-29T05:05:10.807 回答
1

这些问题与可用性审查期间提出的问题相似。解决此类编译错误的方法是切换到命令行并执行正常工作的“mvn clean install”。在某种程度上配置 Eclipse是可能的,您似乎找到了正确的方法。

于 2015-05-31T14:35:00.923 回答
0

更新:我写了一个简短的教程。请让我知道它是否适合您,以及需要改进的地方。

于 2015-04-20T18:08:45.243 回答