From 18ee561dde7b2f77095592a07c1ebcc6c4fd2d56 Mon Sep 17 00:00:00 2001 From: Aviem Zur Date: Wed, 8 Mar 2017 13:59:03 +0200 Subject: [PATCH 1/3] [BEAM-1651] Add IntelliJ code style xml to the project repository --- .../resources/beam/intellij_codestyle.xml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml diff --git a/sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml b/sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml new file mode 100644 index 000000000000..fc4775da37b0 --- /dev/null +++ b/sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml @@ -0,0 +1,58 @@ + + + From 1e10533647f38aa2d479f5ef76f200740c635cce Mon Sep 17 00:00:00 2001 From: Aviem Zur Date: Fri, 10 Mar 2017 07:59:47 +0200 Subject: [PATCH 2/3] [BEAM-1651] Change to use equivalent Eclipse code formatter profile xml --- .../main/resources/beam/beam-codestyle.xml | 329 ++++++++++++++++++ .../resources/beam/intellij_codestyle.xml | 58 --- 2 files changed, 329 insertions(+), 58 deletions(-) create mode 100644 sdks/java/build-tools/src/main/resources/beam/beam-codestyle.xml delete mode 100644 sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml diff --git a/sdks/java/build-tools/src/main/resources/beam/beam-codestyle.xml b/sdks/java/build-tools/src/main/resources/beam/beam-codestyle.xml new file mode 100644 index 000000000000..f722a0e2e525 --- /dev/null +++ b/sdks/java/build-tools/src/main/resources/beam/beam-codestyle.xml @@ -0,0 +1,329 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml b/sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml deleted file mode 100644 index fc4775da37b0..000000000000 --- a/sdks/java/build-tools/src/main/resources/beam/intellij_codestyle.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - From f9e638caae8106e65b11c0eb6a3bf9d91ef9e932 Mon Sep 17 00:00:00 2001 From: Aviem Zur Date: Fri, 10 Mar 2017 08:04:03 +0200 Subject: [PATCH 3/3] [BEAM-1651] Test code style --- sdks/java/build-tools/pom.xml | 31 ++++++++++++- .../beam/codestyle/CodeStyleTestClass.java | 45 +++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java diff --git a/sdks/java/build-tools/pom.xml b/sdks/java/build-tools/pom.xml index bc4cff7b6032..391367ad851d 100644 --- a/sdks/java/build-tools/pom.xml +++ b/sdks/java/build-tools/pom.xml @@ -28,5 +28,34 @@ beam-sdks-java-build-tools Apache Beam :: SDKs :: Java :: Build Tools - + + + + + net.revelc.code.formatter + formatter-maven-plugin + 2.0.1 + + + test-code-style + process-test-sources + + format + + + ${project.basedir}/src/main/resources/beam/beam-codestyle.xml + + ${project.build.testSourceDirectory} + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + diff --git a/sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java b/sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java new file mode 100644 index 000000000000..15aeb4af1ff8 --- /dev/null +++ b/sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java @@ -0,0 +1,45 @@ +/* + * 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. + */ +package org.apache.beam.codestyle; + +import java.util.List; + +/** + * Class to be formatted using beam-codestyle.xml to test it is configured correctly. + */ +public class CodeStyleTestClass { + + public static MyClass withSideInputs(List... sideInputs) { + return new MyClass().myMethod(sideInputs); + } + + /** + * Fake Class. + */ + public static class MyClass { + + private static final String MY_CONSTANT = ""; + + MyClass() { + } + + public MyClass myMethod(List... sideInputs) { + return null; + } + } +}