Giter Club home page Giter Club logo

itm-java-codeformat's Introduction

itm-java-codeformat

Bietet die it@M Codeformatter Regeln für Java als Artefakt an, sodass diese von Spotless automatisiert während des Maven Builds geprüft (mvn spotless:check) bzw. umgesetzt (mvn spotless:apply) werden können.

Verwendung

IDE

java_codestyle_formatter.xml herunterladen und speichern und anschließend in der IDE importieren.

Die gängigen Java IDE's unterstützen den Import von Eclipse XML Profilen.

Eclipse

In den Einstellungen (Window - Preferences) im Reiter Java / Codestyle / Formatter mittels Import die Datei importieren und anschließend mit Apply and Close übernehmen.

Screenshot Eclipse Java Formatter Einstellungen

IntelliJ

In den Einstellungen (File - Settings) im Reiter Editor / Code Style / Java unter den Scheme Actions mittels Import Scheme - Eclipse XML Profile die Datei importieren und anschließend mit Apply übernehmen und Close das Fenster schließen.

Screenshot IntelliJ Java Formatter Einstellungen

VS Code

In VS Code kann direkt auf das XML aus dem Repository in den Workspace Settings verwiesen werden.

<project>/.vscode/settings.json:

{
    "java.format.settings.url": "https://raw.githubusercontent.com/it-at-m/itm-java-codeformat/main/formatter/src/main/resources/itm-java-codeformat/java_codestyle_formatter.xml"
}

Maven

Maven Plugin spotless-maven-plugin hinzufügen:

<plugin>
  <groupId>com.diffplug.spotless</groupId>
  <artifactId>spotless-maven-plugin</artifactId>
  <version>2.28.0</version>
  <dependencies>
    <dependency>
      <groupId>de.muenchen.oss</groupId>
      <artifactId>itm-java-codeformat</artifactId>
      <version>${itm-codeformat.version}</version>
    </dependency>
  </dependencies>
  <configuration>
    <java>
      <includes>
        <include>src/main/java/**/*.java</include> <!-- Check application code -->
        <include>src/test/java/**/*.java</include> <!-- Check application tests code -->
      </includes>
      <eclipse>
        <file>itm-java-codeformat/java_codestyle_formatter.xml</file>
      </eclipse>
      <trimTrailingWhitespace/>
      <endWithNewline/>
    </java>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Dadurch wird beim Build automatisch der Code auf Einhaltung der Formatierungsregeln überprüft (Goal check).

Weitere Einstellungen siehe offizielle Plugin-Dokumentation.

Terminal

Eine Anwendung der Formatierungsregeln (-> Formattieren) kann manuell über mvn spotless:apply durchgeführt werden.

Eine Überprüfung der Formatierungsregeln kann ebenso manuell über mvn spotless:check durchgeführt werden.

Contributing

Bei Änderungswünschen bzw. Änderungsbedarf bitte ein Issue erstellen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.