【问题标题】:Maven Assembly Plugin Issues Warnings for JavaFx 17Maven 程序集插件针对 JavaFx 17 发出警告
【发布时间】:2022-01-24 09:02:47
【问题描述】:

我在构建一个简单的 Java FX 示例时看到了一些警告,该示例也使用 maven-assembly-plugin - 程序集警告输出为:

    [INFO] [INFO] --- maven-assembly-plugin:3.3.0:single (default) @ hellofx ---
    [INFO] Reading assembly descriptor: src/main/assembly/zip.xml
    [WARNING] Failed to build parent project for org.openjfx:javafx-controls:jar:17.0.1
    [WARNING] Failed to build parent project for org.openjfx:javafx-controls:jar:17.0.1
    [WARNING] Failed to build parent project for org.openjfx:javafx-graphics:jar:17.0.1
    [WARNING] Failed to build parent project for org.openjfx:javafx-graphics:jar:17.0.1
    [WARNING] Failed to build parent project for org.openjfx:javafx-base:jar:17.0.1
    [WARNING] Failed to build parent project for org.openjfx:javafx-base:jar:17.0.1

这些警告似乎特定于 JavaFx 库从版本 17 开始,更早 版本,例如版本 11 还可以。

为了重现一个 Maven 项目,创建了以下目录结构

    openjfx-assembly-warnings\data\someData.txt
    openjfx-assembly-warnings\scripts\run.bat
    openjfx-assembly-warnings\src\main\assembly\zip.xml
    openjfx-assembly-warnings\src\main\java\HelloFX.java
    openjfx-assembly-warnings\pom.xml

文件内容为:

someData.txt

This file represents some data 
to be zipped up along with the 
application jar file

运行.bat

    java -cp ".;lib\*" HelloFX

zip.xml

    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 
       http://maven.apache.org/xsd/assembly-1.1.2.xsd">
      <id>zip</id>
      <includeBaseDirectory>true</includeBaseDirectory>
      <formats>
        <format>zip</format>
      </formats>
      <fileSets>
        <fileSet>
          <directory>${project.basedir}/scripts</directory>
          <outputDirectory>/</outputDirectory>
        </fileSet>
        <fileSet>
          <directory>${project.basedir}/data</directory>
          <includes>
            <include>*</include>                
          </includes>           
          <outputDirectory>/data</outputDirectory>
        </fileSet>      
      </fileSets>
      <dependencySets>
        <dependencySet>
          <outputDirectory>/lib</outputDirectory>
        </dependencySet>
      </dependencySets>
    </assembly>

HelloFX.java

    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;

    public class HelloFX extends Application {

      @Override
      public void start(Stage stage) {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + 
                            javaVersion + ".");
        Scene scene = new Scene(new StackPane(l), 640, 480);
        stage.setScene(scene);
        stage.show();
      }

      public static void main(String[] args) {
        launch();
      }
    }

pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <name>hellofx</name>
      <groupId>com.test</groupId>
      <artifactId>hellofx</artifactId>
      <version>1.0.1</version>
      <packaging>jar</packaging>
      <url>http://maven.apache.org</url>
      <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.openjfx</groupId>
          <artifactId>javafx-controls</artifactId>
          <version>17.0.1</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
              <release>11</release>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
              <execution>
                <goals>
                  <goal>java</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <mainClass>HelloFX</mainClass>
            </configuration>
          </plugin>  
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.3.0</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <appendAssemblyId>false</appendAssemblyId>
                  <descriptors>
                    <descriptor>src/main/assembly/zip.xml</descriptor>
                  </descriptors>
                </configuration>
              </execution>
            </executions>
          </plugin>       
        </plugins>
      </build>
    </project>

要重新创建警告输出,请运行 Maven 命令:mvn clean install

除了使用 早期版本的 Java FX 依赖项?

感谢您对此提出任何想法或提示

【问题讨论】:

  • 我不知道你的警告,但为了执行,JavaFX 应该在模块路径而不是类路径上,请参阅 openjfx.io 了解正确的 VM 参数。

标签: maven javafx plugins


【解决方案1】:

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2015-04-14
  • 2015-08-11
  • 2010-11-07
  • 1970-01-01
  • 1970-01-01
  • 2021-12-09
  • 2010-12-12
  • 1970-01-01
  • 2011-04-15
相关资源
最近更新 更多