Skip to content

Commit cd58157

Browse files
authored
Fix floating point handling in Java (#347)
Fix formatting issues, update Maven version.
1 parent 5537559 commit cd58157

File tree

6 files changed

+288
-158
lines changed

6 files changed

+288
-158
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ matrix:
4545
- go test -bench=. ./go -v
4646
- go test ./tile_server/gridserver -v
4747

48-
# Java implementation. Lives in java/, tested with bazel.
48+
# Java implementation. Lives in java/, tested with bazel and maven.
4949
- language: java
5050
jdk: oraclejdk8
5151
env: OLC_PATH=java
5252
script:
5353
- wget -O install.sh "https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-installer-linux-x86_64.sh"
5454
- chmod +x install.sh
5555
- ./install.sh --user && rm -f install.sh
56-
- ~/bin/bazel test --test_output=all ${OLC_PATH}:all
56+
- ~/bin/bazel test --test_output=all ${OLC_PATH}:all && cd ${OLC_PATH} && mvn package
5757

5858
# Javascript Closure library implementation. Lives in js/closure, tested with bazel.
5959
# We use language "c" because bazel will install all the dependencies we need, and we use path "js" for the node_js tests.

java/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
This is the Java implementation of OLC. You can build the library either with [Maven](https://maven.apache.org/) or [Bazel](https://bazel.build/).
44

5+
## Code Style
6+
7+
The Java code must use the Google formatting guidelines. Format is checked using
8+
[google-java-format](https://github.com/google/google-java-format).
9+
10+
The formatting is checked in the tests and formatting errors will cause tests
11+
to fail and comments to be added to your PR.
12+
13+
You can ensure your files are formatted correctly either by installing
14+
google-java-format into your editor, or by running `mvn spotless:check`.
15+
16+
## Static Analysis
17+
18+
Code is checked for common flaws with [PMD](https://pmd.github.io). It can be
19+
executed by running `mvn pmd:pmd pmd:check`.
20+
521
## Building and Testing
622

723
Note: the tests read their data from the [`test_data`](https://github.com/google/open-location-code/tree/master/test_data) directory.
@@ -81,4 +97,4 @@ $
8197

8298
The library is available to import/download via [Maven Central](https://search.maven.org/search?q=g:com.google.openlocationcode).
8399

84-
To update the library, bump the version number in pom.xml and run "mvn clean deploy" from the java folder. See the [docs](https://central.sonatype.org/pages/apache-maven.html) for more info.
100+
To update the library, bump the version number in pom.xml and run "mvn clean deploy" from the java folder. See the [docs](https://central.sonatype.org/pages/apache-maven.html) for more info.

java/pom.xml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<groupId>com.google.openlocationcode</groupId>
1212
<artifactId>openlocationcode</artifactId>
13-
<version>1.0.2</version>
13+
<version>1.0.4</version>
1414
<packaging>jar</packaging>
1515

1616
<name>Open Location Code</name>
@@ -88,9 +88,9 @@
8888
</configuration>
8989
</plugin>
9090
<plugin>
91-
<groupId>com.diffplug.spotless</groupId>
92-
<artifactId>spotless-maven-plugin</artifactId>
93-
<version>1.23.0</version>
91+
<groupId>com.diffplug.spotless</groupId>
92+
<artifactId>spotless-maven-plugin</artifactId>
93+
<version>1.23.0</version>
9494
<dependencies>
9595
<dependency>
9696
<groupId>com.google.googlejavaformat</groupId>
@@ -111,9 +111,55 @@
111111
<trimTrailingWhitespace/>
112112
</java>
113113
</configuration>
114+
<executions>
115+
<execution>
116+
<id>spotless</id>
117+
<phase>compile</phase>
118+
<goals>
119+
<goal>check</goal>
120+
</goals>
121+
</execution>
122+
</executions>
123+
</plugin>
124+
<plugin>
125+
<groupId>org.apache.maven.plugins</groupId>
126+
<artifactId>maven-pmd-plugin</artifactId>
127+
<version>3.9.0</version>
128+
<configuration>
129+
<failOnViolation>true</failOnViolation>
130+
<printFailingErrors>true</printFailingErrors>
131+
<violationSeverity>warning</violationSeverity>
132+
</configuration>
133+
<executions>
134+
<execution>
135+
<id>pmd</id>
136+
<phase>compile</phase>
137+
<goals>
138+
<goal>check</goal>
139+
</goals>
140+
</execution>
141+
</executions>
114142
</plugin>
115143
</plugins>
116144
</build>
145+
146+
<reporting>
147+
<plugins>
148+
<plugin>
149+
<groupId>org.apache.maven.plugins</groupId>
150+
<artifactId>maven-jxr-plugin</artifactId>
151+
<version>2.3</version>
152+
</plugin>
153+
<plugin>
154+
<groupId>org.apache.maven.plugins</groupId>
155+
<artifactId>maven-pmd-plugin</artifactId>
156+
</plugin>
157+
<plugin>
158+
<groupId>com.diffplug.spotless</groupId>
159+
<artifactId>spotless-maven-plugin</artifactId>
160+
</plugin>
161+
</plugins>
162+
</reporting>
117163

118164
<distributionManagement>
119165
<snapshotRepository>

0 commit comments

Comments
 (0)