Skip to content

Commit c98df26

Browse files
author
jianggang
authored
🎨 chore: add spotless format checker (#35)
🎨 chore: add spotless format checker
1 parent bd1948e commit c98df26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+995
-146
lines changed

.github/misc/license-header

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<profiles version="22">
3+
<profile kind="CodeFormatterProfile" name="Liquid Backend Services" version="13">
4+
<setting id="org.eclipse.jdt.core.compiler.source" value="1.8" />
5+
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8" />
6+
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8" />
7+
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false" />
8+
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4" />
9+
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120" />
10+
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120" />
11+
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space" />
12+
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="1" />
13+
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1" />
14+
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false" />
15+
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false" />
16+
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert" />
17+
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert" />
18+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16" />
19+
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert" />
20+
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert" />
21+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80" />
22+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16" />
23+
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1" />
24+
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2" />
25+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="160" />
26+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="10" />
27+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="106" />
28+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="106" />
29+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="106" />
30+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80" />
31+
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
32+
</profile>
33+
</profiles>

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ jobs:
1919
java-version: '11'
2020
distribution: 'temurin'
2121
cache: maven
22+
23+
- name: Spotless check
24+
run: mvn spotless:check
25+
2226
- name: Build with Maven
2327
run: mvn -B package --file pom.xml
2428

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@ SDK is designed primarily for use in multi-user systems such as web servers and
1212

1313
Reading the short [Introduction](https://docs.featureprobe.io/reference/sdk-introduction) will help to understand the code blow more easily. [中文](https://docs.featureprobe.io/zh-CN/reference/sdk-introduction)
1414

15-
1615
## How to Use This SDK
1716

1817
See [SDK Doc](https://docs.featureprobe.io/how-to/Server-Side%20SDKs/java-sdk) for detail. [中文](https://docs.featureprobe.io/zh-CN/how-to/Server-Side%20SDKs/java-sdk)
1918

2019
## Contributing
2120

22-
We are working on continue evolving FeatureProbe core, making it flexible and easier to use.
23-
Development of FeatureProbe happens in the open on GitHub, and we are grateful to the
21+
We are working on continue evolving FeatureProbe core, making it flexible and easier to use.
22+
Development of FeatureProbe happens in the open on GitHub, and we are grateful to the
2423
community for contributing bugfixes and improvements.
2524

26-
Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md)
25+
Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md)
2726
for details on our code of conduct, and the process for taking part in improving FeatureProbe.
2827

2928
## License

pom.xml

Lines changed: 93 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
43
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
54
<modelVersion>4.0.0</modelVersion>
65

76
<groupId>com.featureprobe</groupId>
87
<artifactId>server-sdk-java</artifactId>
98
<version>2.0.1</version>
109
<name>server-sdk-java</name>
11-
<url>https://github.com/FeatureProbe/server-sdk-java</url>
1210
<description>FeatureProbe Server Side SDK for Java</description>
1311

14-
<developers>
15-
<developer>
16-
<id>KaKa</id>
17-
<name>KaKa Jiang</name>
18-
<roles>
19-
<role>lead developer</role>
20-
</roles>
21-
</developer>
22-
</developers>
23-
24-
<licenses>
25-
<license>
26-
<name>Apache License, Version 2.0</name>
27-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
28-
<distribution>repo</distribution>
29-
<comments>A business-friendly OSS license</comments>
30-
</license>
31-
</licenses>
32-
33-
<scm>
34-
<connection>scm:git@github.com:FeatureProbe/server-sdk-java.git</connection>
35-
<developerConnection>scm:git@github.com:FeatureProbe/server-sdk-java.git</developerConnection>
36-
<url>https://github.com/FeatureProbe/server-sdk-java</url>
37-
</scm>
38-
3912
<properties>
4013
<java.version>1.8</java.version>
4114
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -109,25 +82,29 @@
10982
<scope>test</scope>
11083
</dependency>
11184
<!-- Optional dependencies for using Spock -->
112-
<dependency> <!-- use a specific Groovy version rather than the one specified by spock-core -->
85+
<dependency>
86+
<!-- use a specific Groovy version rather than the one specified by spock-core -->
11387
<groupId>org.codehaus.groovy</groupId>
11488
<artifactId>groovy</artifactId>
11589
<version>${groovy.version}</version>
11690
<scope>test</scope>
11791
</dependency>
118-
<dependency> <!-- enables mocking of classes (in addition to interfaces) -->
92+
<dependency>
93+
<!-- enables mocking of classes (in addition to interfaces) -->
11994
<groupId>net.bytebuddy</groupId>
12095
<artifactId>byte-buddy</artifactId>
12196
<version>1.12.7</version>
12297
<scope>test</scope>
12398
</dependency>
124-
<dependency> <!-- enables mocking of classes without default constructor (together with ByteBuddy or CGLIB) -->
99+
<dependency>
100+
<!-- enables mocking of classes without default constructor (together with ByteBuddy or CGLIB) -->
125101
<groupId>org.objenesis</groupId>
126102
<artifactId>objenesis</artifactId>
127103
<version>3.2</version>
128104
<scope>test</scope>
129105
</dependency>
130-
<dependency> <!-- only required if Hamcrest matchers are used -->
106+
<dependency>
107+
<!-- only required if Hamcrest matchers are used -->
131108
<groupId>org.hamcrest</groupId>
132109
<artifactId>hamcrest-core</artifactId>
133110
<version>2.2</version>
@@ -148,17 +125,6 @@
148125
</dependency>
149126
</dependencies>
150127

151-
<distributionManagement>
152-
<snapshotRepository>
153-
<id>ossrh</id>
154-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
155-
</snapshotRepository>
156-
<repository>
157-
<id>ossrh</id>
158-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
159-
</repository>
160-
</distributionManagement>
161-
162128
<build>
163129
<plugins>
164130
<plugin>
@@ -191,7 +157,8 @@
191157
<artifactId>maven-surefire-plugin</artifactId>
192158
<version>3.0.0-M5</version>
193159
<configuration>
194-
<useModulePath>false</useModulePath> <!-- https://issues.apache.org/jira/browse/SUREFIRE-1809 -->
160+
<useModulePath>false</useModulePath>
161+
<!-- https://issues.apache.org/jira/browse/SUREFIRE-1809 -->
195162
<useFile>false</useFile>
196163
<includes>
197164
<include>**/*Test</include>
@@ -207,6 +174,48 @@
207174
</statelessTestsetReporter>
208175
</configuration>
209176
</plugin>
177+
<plugin>
178+
<groupId>com.diffplug.spotless</groupId>
179+
<artifactId>spotless-maven-plugin</artifactId>
180+
<version>2.25.0</version>
181+
<configuration>
182+
<java>
183+
<eclipse>
184+
<file>.github/misc/spotless-formatter.xml</file>
185+
</eclipse>
186+
<removeUnusedImports />
187+
<licenseHeader>
188+
<file>.github/misc/license-header</file>
189+
</licenseHeader>
190+
</java>
191+
<pom>
192+
<sortPom>
193+
<encoding>UTF-8</encoding>
194+
<nrOfIndentSpace>4</nrOfIndentSpace>
195+
<keepBlankLines>true</keepBlankLines>
196+
<indentBlankLines>false</indentBlankLines>
197+
<indentSchemaLocation>true</indentSchemaLocation>
198+
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
199+
<sortModules>false</sortModules>
200+
<sortExecutions>false</sortExecutions>
201+
<predefinedSortOrder>custom_1</predefinedSortOrder>
202+
<expandEmptyElements>false</expandEmptyElements>
203+
<sortProperties>false</sortProperties>
204+
</sortPom>
205+
<replace>
206+
<name>Leading blank line</name>
207+
<search>project</search>
208+
<replacement>project</replacement>
209+
</replace>
210+
</pom>
211+
<markdown>
212+
<includes>
213+
<include>**/*.md</include>
214+
</includes>
215+
<flexmark />
216+
</markdown>
217+
</configuration>
218+
</plugin>
210219
<plugin>
211220
<groupId>org.jacoco</groupId>
212221
<artifactId>jacoco-maven-plugin</artifactId>
@@ -226,10 +235,10 @@
226235
</execution>
227236
<execution>
228237
<id>jacoco-site</id>
229-
<phase>test</phase>
230238
<goals>
231239
<goal>report</goal>
232240
</goals>
241+
<phase>test</phase>
233242
</execution>
234243
</executions>
235244
</plugin>
@@ -289,10 +298,10 @@
289298
<executions>
290299
<execution>
291300
<id>sign-artifacts</id>
292-
<phase>verify</phase>
293301
<goals>
294302
<goal>sign</goal>
295303
</goals>
304+
<phase>verify</phase>
296305
<configuration>
297306
<gpgArguments>
298307
<arg>--pinentry-mode</arg>
@@ -322,10 +331,10 @@
322331
<executions>
323332
<execution>
324333
<id>make-assembly</id>
325-
<phase>package</phase>
326334
<goals>
327335
<goal>single</goal>
328336
</goals>
337+
<phase>package</phase>
329338

330339
</execution>
331340
</executions>
@@ -354,4 +363,41 @@
354363
</plugin>
355364
</plugins>
356365
</reporting>
366+
<url>https://github.com/FeatureProbe/server-sdk-java</url>
367+
368+
<licenses>
369+
<license>
370+
<name>Apache License, Version 2.0</name>
371+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
372+
<distribution>repo</distribution>
373+
<comments>A business-friendly OSS license</comments>
374+
</license>
375+
</licenses>
376+
377+
<developers>
378+
<developer>
379+
<id>KaKa</id>
380+
<name>KaKa Jiang</name>
381+
<roles>
382+
<role>lead developer</role>
383+
</roles>
384+
</developer>
385+
</developers>
386+
387+
<scm>
388+
<connection>scm:git@github.com:FeatureProbe/server-sdk-java.git</connection>
389+
<developerConnection>scm:git@github.com:FeatureProbe/server-sdk-java.git</developerConnection>
390+
<url>https://github.com/FeatureProbe/server-sdk-java</url>
391+
</scm>
392+
393+
<distributionManagement>
394+
<repository>
395+
<id>ossrh</id>
396+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
397+
</repository>
398+
<snapshotRepository>
399+
<id>ossrh</id>
400+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
401+
</snapshotRepository>
402+
</distributionManagement>
357403
</project>

src/main/java/com/featureprobe/sdk/example/FeatureProbeDemo.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package com.featureprobe.sdk.example;
219

320
import com.featureprobe.sdk.server.FPConfig;
@@ -20,19 +37,18 @@ public class FeatureProbeDemo {
2037
// FeatureProbe server URL for local docker
2138
private static final String FEATURE_PROBE_SERVER_URL = "http://localhost:4009/server"; // "https://featureprobe.io/server";
2239

23-
2440
// Server Side SDK Key for your project and environment
2541
public static final String FEATURE_PROBE_SERVER_SDK_KEY = "server-8ed48815ef044428826787e9a238b9c6a479f98c";
2642

2743
public static void main(String[] args) throws IOException, InterruptedException {
2844

29-
Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
45+
Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
3046
root.setLevel(Level.WARN);
3147

3248
final FPConfig config = FPConfig.builder()
33-
.remoteUri(FEATURE_PROBE_SERVER_URL)
34-
.startWait(5L, TimeUnit.SECONDS)
35-
.build();
49+
.remoteUri(FEATURE_PROBE_SERVER_URL)
50+
.startWait(5L, TimeUnit.SECONDS)
51+
.build();
3652

3753
// Init FeatureProbe, share this FeatureProbe instance in your project.
3854
final FeatureProbe fpClient = new FeatureProbe(FEATURE_PROBE_SERVER_SDK_KEY, config);
@@ -43,7 +59,7 @@ public static void main(String[] args) throws IOException, InterruptedException
4359

4460
// Create one user.
4561
FPUser user = new FPUser()
46-
.with("userId", "00001"); // "userId" is used in rules, should be filled in.
62+
.with("userId", "00001"); // "userId" is used in rules, should be filled in.
4763

4864
// Get toggle result for this user.
4965
final String YOUR_TOGGLE_KEY = "campaign_allow_list";
@@ -56,7 +72,6 @@ public static void main(String[] args) throws IOException, InterruptedException
5672
System.out.println("detail:" + isOpenDetail.getReason());
5773
System.out.println("rule index:" + isOpenDetail.getRuleIndex());
5874

59-
6075
// Simulate conversion rate of 1000 users for a new feature
6176
final String YOUR_CUSTOM_EVENT_NAME = "new_feature_conversion";
6277
for (int i = 0; i < 1000; i++) {

0 commit comments

Comments
 (0)