1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【JavaFX】Eclipseのアクセス許可をbuild.gradleに書く方法

Last updated at Posted at 2019-09-20

gradlew eclipseの度にエラーになっちゃう

image.png

Access restriction: The type 'TransferMode' is not API (restriction on required library 'C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jfxrt.jar')

これは要するに以下の場所からアクセス許可を与えやればいいとの事である。

image.png

上の画像右、Editから編集してjavafx/**をルールでAccessibleに追加して許可してやれば良いわけだが。
image.png

流石にgradlew eclipseなんてコマンドは依存関係を更新する度に打つので毎度毎度こんな設定をさせられるのは鬱陶しい。

誰かがgitからcloneしたときに「これエラー出てるんですけど(笑)」とか言われるのも実に腹立たしい。

というわけで、gradleに書く方法。

build.gradle
import org.gradle.plugins.ide.eclipse.model.AccessRule

eclipse {
    classpath {
        file {
            whenMerged {
                def jre = entries.find { it.path.contains 'org.eclipse.jdt.launching.JRE_CONTAINER' }
                jre.accessRules.add(new AccessRule('accessible', 'javafx/**'))
            }
        }
    }
}

こんな感じ。
これでEclipseの.classpathに以下のように追加され、俺はマウスを使う量が減り、イライラが治る事で戦争が減り世界が平和になるという仕組みである。

    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/">
        <accessrules>
            <accessrule kind="accessible" pattern="javafx/**"/>
        </accessrules>
    </classpathentry>

いつもありがとう、スタックオーバーフローの人。
それと、【JavaFX】Eclipseで、アクセス制限: The type '?' is not API(? ex: JavaFX)と出た時の対処法まとめ@smk7758さん。

よし大体定時だ。帰るぞ俺は。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?