Collection of common reusable resources for code formatting and code checks in EMF.cloud Java projects.
The eclipse directory contains the EMF.cloud settings for formatting and clean-up of Java code as well as code templates. You can use these settings on a per-project basis by simply copying the .settings directory into your Eclipse project.
Alternatively, these settings can also be configured globally. This can be done in the preferences (Window > Preferences > Java > Code Style) by creating a new profile and import the settings from the corresponding .xml file of the eclipse directory.
The code style settings are intended for usage in the Eclipse IDE, however, some alternative IDEs provide support to import Eclipse-specific code formatter settings.
If you want to use them in IntelliJ Idea you can follow the instructions in this blog post.
The VSCode Java Language support also offers the possibility to configure an xml-based Eclipse formatter.
Checkstyle is used for static code analysis in EMF.cloud Java projects. A custom checkstyle configuration for EMF.cloud is provided and
can be integrated in the build process via maven as well as directly into the Eclipse IDE.
The recommended checkstyle version is 8.44.
For a smoother transition period we also maintain the second-to-last revision of checkstyle configuration (currently 8.39) but we recommend to switch to the latest revision as soon as possible.
The directory org.eclipse.emfcloud.checkstyle contains the EMF.cloud checkstyle configuration bundled as a maven artifact. The artifact can be used in a maven build to integrate checkstyle based on the EMF.cloud configuration.
The pom.xml of your project has to be configured like this:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.44</version>
</dependency>
<dependency>
<groupId>org.eclipse.emfcloud</groupId>
<artifactId>org.eclipse.emfcloud.checkstyle</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<configLocation>emfcloud-checkstyle-8.44.xml</configLocation>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>If you are using a SNAPSHOT version of `org.eclipse.emfcloud.checkstyle` you also have to specify the Sonatype snapshot repository:
<project>
...
<repositories>
<repository>
<id>sonatype</id>
<name>Sonatype</name>
<url>https://oss.sonatype.org/content/groups/public</url>
</repository>
</repositories>
...
</project>Checkstyle integration into the Eclipse IDE can be achieved with the help of the Eclipse Checkstyle Plugin. Go to https://checkstyle.org/eclipse-cs/#!/ and follow the instructions to install the plugin.
The eclipse directory contains a preconfigured .checkstyle file to use the EMF.cloud checkstyle rules in your Eclipse project. Simply copy the file into your Eclipse project and then activate checkstyle with: right-click on your project > Checkstyle > Activate checkstyle.
Alternatively, you can also setup a manual configuration. Go to Window > Preferences > Checkstyle and setup new Global Check Configuration by clicking the 'New...' button.
As type choose 'Remote Configuration' and as location use the raw link to the custom checkstyle configuration: