Skip to content

Commit

Permalink
[CAMEL-14578] Add support for exclusion regex to not format DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Aug 20, 2020
1 parent c58bdcd commit 83a69be
Show file tree
Hide file tree
Showing 18 changed files with 1,348 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
-->
<profiles version="8">
<profile name="Camel Java Conventions" version="8" kind="CodeFormatterProfile">
<setting id="org.apache.camel.formatter.java.exclusion_pattern"
value="\b((from|fromF)\([^;]*\.end[^;]*?\)|rest\([^;]*?\));"/>

<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
Expand Down
1 change: 0 additions & 1 deletion camel-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@
<maven-archetype-packaging-version>2.3</maven-archetype-packaging-version>
<maven-archetype-plugin-version>3.0.1</maven-archetype-plugin-version>
<maven-assembly-plugin-version>3.0.0</maven-assembly-plugin-version>
<maven-bundle-plugin-version>4.2.1</maven-bundle-plugin-version>
<maven-checkstyle-plugin-version>3.1.1</maven-checkstyle-plugin-version>
<maven-checkstyle-version>8.35</maven-checkstyle-version>
<maven-jar-plugin-version>3.2.0</maven-jar-plugin-version>
Expand Down
4 changes: 4 additions & 0 deletions catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-format-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
4 changes: 4 additions & 0 deletions components/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-format-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
4 changes: 4 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-format-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
10 changes: 10 additions & 0 deletions init/camel-format-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# camel-format-plugin

The plugin is used to reformat the source code at build time. It repackages
the `net.revelc.code.formatter:formatter-maven-plugin`, adding a way to exclude
portions of the source file from being formatted. This is useful to avoid
reformating inside the DSL which is usually indented with semantics.

The only modified file is the `JavaFormatter` class. The two other `FormatterMojo`
and `ValidateMojo` classes are provided so that the maven plugin plugin can easily detect
the goals.
84 changes: 84 additions & 0 deletions init/camel-format-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.camel</groupId>
<artifactId>init</artifactId>
<version>3.5.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>camel-format-plugin</artifactId>
<packaging>maven-plugin</packaging>

<name>Camel :: Maven Plugins :: Enhanced Formatter Plugin</name>
<description>Plugin to automatically reformat the code</description>

<dependencies>
<dependency>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>${formatter-maven-plugin.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>net.revelc.code.formatter:formatter-maven-plugin</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 83a69be

Please sign in to comment.