maven在编译eclipse应用程序时找不到javafx 11

问题描述 投票:0回答:1

我有一个使用javafx 11的eclipse应用程序。由于缺少更好的解决方案,我在/opt/javafx-sdk-11.0.2中安装了javafx,产品定义包含--module-path /opt/javafx-sdk-11.0.2/lib/ --add-modules=javafx.controls作为vm参数,而.classpath包含以下行:

<classpathentry kind="lib" path="/opt/javafx-sdk-11.0.2/lib/javafx.base.jar"/>
<classpathentry kind="lib" path="/opt/javafx-sdk-11.0.2/lib/javafx.controls.jar"/>
<classpathentry kind="lib" path="/opt/javafx-sdk-11.0.2/lib/javafx.graphics.jar"/>

我的pom.xml看起来像这样:

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.rulez.magwas</groupId>
    <artifactId>zenta3</artifactId>
    <version>3.0.0-SNAPSHOT</version>
  </parent>

  <groupId>zenta3-editor</groupId>
  <artifactId>org.rulez.demokracia.zenta3.editor</artifactId>
  <packaging>eclipse-plugin</packaging>

  <build>
    <plugins>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.1</version>
            <configuration>
                <mainClass>org.openjfx.App</mainClass>
            </configuration>
        </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>${jdk.version}</release>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>java</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <mainClass>ZentaApplication</mainClass>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11.0.2</version>
    </dependency>
</dependencies>

</project>

父pom包含属性,repos和以下tycho构建插件配置:

  <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-packaging-plugin</artifactId>
    <version>${tycho-version}</version>
    <configuration>
      <archive>
        <manifestEntries>
          <Bundle-RequiredExecutionEnvironment>${jdk.full.version}</Bundle-RequiredExecutionEnvironment>
        </manifestEntries>
      </archive>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-maven-plugin</artifactId>
    <version>${tycho-version}</version>
    <extensions>true</extensions>
  </plugin>
  <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>target-platform-configuration</artifactId>
    <version>${tycho-version}</version>
    <configuration>
      <executionEnvironment>${jdk.full.version}</executionEnvironment>
      <dependency-resolution>
        <extraRequirements>
          <requirement>
            <type>eclipse-plugin</type>
            <id>org.eclipse.osgi.compatibility.state</id>
            <versionRange>0.0.0</versionRange>
          </requirement>
        </extraRequirements>
      </dependency-resolution>
      <environments>
        <environment>
          <os>linux</os>
          <ws>gtk</ws>
          <arch>x86_64</arch>
        </environment>
        <environment>
          <os>win32</os>
          <ws>win32</ws>
          <arch>x86_64</arch>
        </environment>
        <environment>
          <os>macosx</os>
          <ws>cocoa</ws>
          <arch>x86_64</arch>
        </environment>
      </environments>
    </configuration>
  </plugin>
</plugins>

jdk.version是11,但也尝试了10。关于它的奇怪之处我记得我可以用maven编译它,但是现在无法编译它。

错误:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.4.0:compile (default-compile) on project org.rulez.demokracia.zenta3.editor: Compilation failure: Compilation failure: 
[ERROR] /project/mag/Zenta/zenta3/ui/src/main/java/org/rulez/demokracia/zenta3/editor/parts/handles/DeleteElementHandlePart.java: 
[ERROR]     package org.rulez.demokracia.zenta3.editor.parts.handles;
[ERROR]     ^
[ERROR] The type javafx.scene.paint.Color cannot be resolved. It is indirectly referenced from required .class files
[ERROR] /project/mag/Zenta/zenta3/ui/src/main/java/org/rulez/demokracia/zenta3/editor/parts/handles/DeleteElementHandlePart.java:[17] 
[ERROR]     public class DeleteElementHandlePart extends AbstractHandlePart<Group> {
[ERROR]                                                                     ^^^^^
[ERROR] Group cannot be resolved to a type
[ERROR] 2 problems (2 errors)
eclipse maven tycho javafx-11
1个回答
0
投票

将javafx的所有jar放到项目的lib文件夹中,并将它们列在classpath中。但它似乎更像是一种解决方法而不是一种解决方案,我无法弄清楚如何设置产品的启动配置才能真正启动它。

© www.soinside.com 2019 - 2024. All rights reserved.