编译Eclipse应用程序时,maven无法找到javafx 11

时间:2019-04-13 08:31:01

标签: eclipse maven tycho javafx-11

我有一个使用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包含以下几行: / p>

<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包含属性,存储库和以下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)

1 个答案:

答案 0 :(得分:0)

将所有javafx的jar放入项目的lib文件夹中,并在classpath中列出它们。但这似乎更像是一种解决方法,而不是解决方案,而且我无法弄清楚如何设置产品的启动配置以使其能够实际启动。