Skip to content

Commit cb99dfa

Browse files
authored
Relax ImportOrder checkstyle for sample apps (spring-attic#2062)
We have two different usecases when someone is trying to run a sample: * people who want to try the sample apps, but don't intend to contribute any changes to the codebase. For them, checkstyle is just a distraction from what they are trying to get done -- learn how to use our integrations. * actual contributors, who should be bound by checkstyle because our codebase should be consistent. What this change does now is: * guarantee that incorrect style does not make it into the codebase (because the new profile runs on Travis at install phase). * make it possible to run full checkstyle locally (so the contributor does not get surprised by new checkstyle requirements after PR is created). * for casual users, default to not enforcing checkstyle on sample apps . Fixes spring-attic#2028.
1 parent c9d9527 commit cb99dfa

File tree

3 files changed

+60
-48
lines changed

3 files changed

+60
-48
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ script:
3333
./mvnw test -B -P codecov ${INTEGRATION_TEST_FLAGS} && bash <(curl -s https://codecov.io/bash) -F integration;
3434
fi;
3535
install:
36-
- ./mvnw -T 1.5C install -DskipTests=true -Dmaven.javadoc.skip=true -Dspring.profiles.active=spring -B -V
36+
- ./mvnw -T 1.5C install -DskipTests=true -Dmaven.javadoc.skip=true -Dspring.profiles.active=spring -P full-checkstyle -B -V
3737
before_install:
3838
- if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
3939
openssl aes-256-cbc -K $encrypted_1ef8dfbdb114_key -iv $encrypted_1ef8dfbdb114_iv -in travis.tar.gz.enc -out travis.tar.gz -d;

CONTRIBUTING.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Run `./mvnw clean test` in the root directory of the project to run the tests.
1414
The `./mvnw` is a self-contained https://maven.apache.org/[Maven] wrapper that allows you to build the project without having Maven installed on your local machine.
1515
+
1616
You can run the tests of a specific module by using the `-f` flag like this: `./mvnw clean test -f spring-cloud-gcp-pubsub`
17+
+
18+
If you are contributing to a sample application, please use `full-checkstyle` maven profile to validate code style locally: `./mvnw clean test -P full-checkstyle`.
1719

1820
3. (Optional) Install the https://cloud.google.com/sdk/docs/[Google Cloud SDK].
1921
The Google Cloud SDK a set of tools that you can use to manage resources and applications hosted on Google Cloud Platform.

spring-cloud-gcp-samples/pom.xml

+57-47
Original file line numberDiff line numberDiff line change
@@ -52,55 +52,65 @@
5252
<module>spring-cloud-gcp-pubsub-stream-binder-functional-sample</module>
5353
</modules>
5454

55+
<!-- Checkstyle on samples invoked during CI or manually when running locally. -->
56+
<profiles>
57+
<profile>
58+
<id>full-checkstyle</id>
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-checkstyle-plugin</artifactId>
64+
<version>3.0.0</version>
65+
<dependencies>
66+
<dependency>
67+
<groupId>com.puppycrawl.tools</groupId>
68+
<artifactId>checkstyle</artifactId>
69+
<version>8.18</version>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.spring.javaformat</groupId>
73+
<artifactId>spring-javaformat-checkstyle</artifactId>
74+
<version>0.0.9</version>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.springframework.cloud</groupId>
78+
<artifactId>spring-cloud-build-tools</artifactId>
79+
<version>${spring-cloud-build-tools.version}</version>
80+
</dependency>
81+
</dependencies>
82+
<executions>
83+
<execution>
84+
<id>checkstyle-validation</id>
85+
<phase>validate</phase>
86+
<configuration>
87+
<propertyExpansion>
88+
checkstyle.build.directory=${project.build.directory}
89+
checkstyle.suppressions.file=${checkstyle.suppressions.file}
90+
checkstyle.additional.suppressions.file=${checkstyle.additional.suppressions.file}
91+
</propertyExpansion>
92+
<configLocation>checkstyle.xml</configLocation>
93+
<headerLocation>checkstyle-header.txt</headerLocation>
94+
<consoleOutput>true</consoleOutput>
95+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
96+
<failsOnError>true</failsOnError>
97+
<failOnViolation>true</failOnViolation>
98+
<suppressionsLocation>../src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
99+
<violationSeverity>warning</violationSeverity>
100+
</configuration>
101+
<goals>
102+
<goal>check</goal>
103+
</goals>
104+
</execution>
105+
</executions>
106+
</plugin>
107+
</plugins>
108+
</build>
109+
</profile>
110+
</profiles>
111+
55112
<build>
56113
<plugins>
57-
<plugin>
58-
<groupId>org.apache.maven.plugins</groupId>
59-
<artifactId>maven-checkstyle-plugin</artifactId>
60-
<version>3.0.0</version>
61-
<dependencies>
62-
<dependency>
63-
<groupId>com.puppycrawl.tools</groupId>
64-
<artifactId>checkstyle</artifactId>
65-
<version>8.18</version>
66-
</dependency>
67-
<dependency>
68-
<groupId>io.spring.javaformat</groupId>
69-
<artifactId>spring-javaformat-checkstyle</artifactId>
70-
<version>0.0.9</version>
71-
</dependency>
72-
<dependency>
73-
<groupId>org.springframework.cloud</groupId>
74-
<artifactId>spring-cloud-build-tools</artifactId>
75-
<version>${spring-cloud-build-tools.version}</version>
76-
</dependency>
77-
</dependencies>
78-
<executions>
79-
<execution>
80-
<id>checkstyle-validation</id>
81-
<phase>validate</phase>
82-
<configuration>
83-
<propertyExpansion>
84-
checkstyle.build.directory=${project.build.directory}
85-
checkstyle.suppressions.file=${checkstyle.suppressions.file}
86-
checkstyle.additional.suppressions.file=${checkstyle.additional.suppressions.file}
87-
</propertyExpansion>
88-
<configLocation>checkstyle.xml</configLocation>
89-
<headerLocation>checkstyle-header.txt</headerLocation>
90-
<consoleOutput>true</consoleOutput>
91-
<includeTestSourceDirectory>true</includeTestSourceDirectory>
92-
<failsOnError>true</failsOnError>
93-
<failOnViolation>true</failOnViolation>
94-
<suppressionsLocation>../src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
95-
<violationSeverity>warning</violationSeverity>
96-
</configuration>
97-
<goals>
98-
<goal>check</goal>
99-
</goals>
100-
</execution>
101-
</executions>
102-
</plugin>
103-
104114
<plugin>
105115
<artifactId>maven-deploy-plugin</artifactId>
106116
<configuration>

0 commit comments

Comments
 (0)