LoginSignup
1
5

More than 5 years have passed since last update.

【Gradle】【checkstyle】Eclipseから「Gradleプロジェクトのリフレッシュ」でCheckstyleのアクティブ設定が外れる場合の対処法

Posted at

こちらのサイトを参考にしました。
http://irtakt.hatenablog.com/entry/2014/05/04/233312

環境によって、発生したりしなかったりするらしいのですが、
EclipseのプロジェクトのプロパティでCheckstyle⇒「このプロジェクトでCheckstyleをアクティブにする」にチェックしたのに、
「Gradleプロジェクトのリフレッシュ」1を実行するとチェックが外れてしまう場合の対処法です。

image.png

image.png

で、チェックが外れる

原因

原因は、「Gradleプロジェクトのリフレッシュ」でgradleのeclipseプラグインが呼ばれ、
「.project」ファイルが再構築され、CheckstyleのbuildCommandとnatureが外れてしまうためです。

対処

build.gradleファイルに以下の記述を足します。

build.gradle
apply plugin: 'eclipse'

eclipse {
    project {
        natures 'net.sf.eclipsecs.core.CheckstyleNature'
        buildCommand 'net.sf.eclipsecs.core.CheckstyleBuilder'
    }
}

これで、「Gradleプロジェクトのリフレッシュ」1した際に「.project」ファイルにCheckstyle用のbuildCommandとnatureが記述され、EclipseのCheckstyleアクティブ設定を常にONにすることができます。

下記は作成された「.project」ファイル

.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <!-- ・・・・ -->
    <buildSpec>
        <!-- ・・・・ -->
        <buildCommand>
            <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <!-- ・・・・ -->
    </buildSpec>
    <natures>
        <!-- ・・・・ -->
        <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
        <!-- ・・・・ -->
    </natures>
</projectDescription>


  1. または gradle eclipse 実行。 

1
5
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
5