Ste*_*fan 4 java eclipse javafx maven m2e
为了避免对jfxrt.jar的非法访问警告,我手动将类路径文件更改为包括访问规则:
想要的类路径条目
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
<accessrules>
<accessrule kind="accessible" pattern="javafx/**"/>
<accessrule kind="accessible" pattern="com/sun/javafx/**"/>
</accessrules>
</classpathentry>
Run Code Online (Sandbox Code Playgroud)
如果我执行pom.xml文件,则标签accessrule会被删除,新条目为
当前由pom.xml / M2E生成的类路径条目
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Run Code Online (Sandbox Code Playgroud)
这是因为有关访问规则的信息未包含在我的pom.xml文件中。如何修改pom.xml文件以生成所需的类路径文件?
我可以对Maven-compiler-plugin使用一些配置吗?
还是我必须使用一些额外的Maven插件来修改类路径文本文件?
还是根本无法在pom.xml文件中解决此问题,而我将不得不为M2E编写功能请求?
这是我的pom.xml文件中的一个片段(我使用pom打包):
当前的pom.xml条目用于编译阶段
<!-- ### COMPILE ### phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- specify current java version here: -->
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile-execution</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>org.treez.test-compile-execution</id>
<phase>org.treez.test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我找到了一种解决方法来修复.classfile。需要两个步骤:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>prepare-package</phase>
<configuration>
<tasks>
<replace
token= "JavaSE-1.8">"
value="JavaSE-1.8"> <accessrules> <accessrule kind="accessible" pattern="javafx/**"/> <accessrule kind="accessible" pattern="com/sun/javafx/**"/> </accessrules>"
file=".classpath"
>
</replace>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>1.8</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2646 次 |
| 最近记录: |