Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to eclipse formatter to support multiple IDEs #122

Merged
merged 11 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

name: Bug report
about: Create a report to help improve Planetiler
title: "[BUG] "
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

name: Feature request
about: Suggest an idea for Planetiler
title: "[FEATURE] "
Expand Down
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ updates:
ignore:
- dependency-name: "com.graphhopper:graphhopper-reader-osm"
- package-ecosystem: maven
directory: "/planetiler-examples"
# workaround for https://github.com/dependabot/dependabot-core/issues/4425
directory: "/.github/planetiler-examples-dependabot"
open-pull-requests-limit: 1
schedule:
interval: daily
Expand Down
22 changes: 22 additions & 0 deletions .github/planetiler-examples-dependabot/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is just a workaround for https://github.com/dependabot/dependabot-core/issues/4425 so that
dependabot can update planetiler-examples/standalone.pom.xml without referring directly to a pom.xml with a
non-standard name.
-->
<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>

<groupId>com.onthegomap.planetiler</groupId>
<artifactId>planetiler-examples-parent-for-dependabot</artifactId>
<version>HEAD</version>
<packaging>pom</packaging>

<modules>
<module>../../planetiler-examples/pom.xml</module>
</modules>
</project>
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
cache: 'maven'
- name: Build with mvnw (linux/mac)
if: ${{ !contains(matrix.os, 'windows') }}
run: ./mvnw ${{matrix.args}} --batch-mode -no-transfer-progress package jib:buildTar --file pom.xml
run: ./mvnw ${{matrix.args}} --batch-mode -no-transfer-progress package verify jib:buildTar --file pom.xml
- name: Build with mvnw.cmd (windows)
if: ${{ contains(matrix.os, 'windows') }}
run: mvnw.cmd ${{matrix.args}} --batch-mode -no-transfer-progress package jib:buildTar --file pom.xml
run: mvnw.cmd ${{matrix.args}} --batch-mode -no-transfer-progress package verify jib:buildTar --file pom.xml
shell: cmd

regenerate:
Expand All @@ -54,7 +54,7 @@ jobs:
cache: 'maven'
- run: ./scripts/regenerate-openmaptiles.sh
- run: ./mvnw -DskipTests --batch-mode -no-transfer-progress clean install -pl planetiler-basemap -am
- run: ./mvnw --batch-mode -no-transfer-progress test -pl planetiler-basemap
- run: ./mvnw --batch-mode -no-transfer-progress verify -pl planetiler-basemap

examples:
name: Example project
Expand All @@ -69,7 +69,7 @@ jobs:
java-version: 17
distribution: 'temurin'
- name: Build and test
run: mvn --batch-mode -no-transfer-progress package --file pom.xml
run: mvn --batch-mode -no-transfer-progress package --file standalone.pom.xml
working-directory: planetiler-examples
- name: Find jar
run: mv target/*with-deps.jar ./run.jar
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ target/
!.mvn/wrapper/*.jar
*.log

# idea
*/.idea
.idea/*
*.iml
!.idea/codeStyles
!.idea/vcs.xml
!.idea/eclipseCodeFormatter.xml

# eclipse
.classpath
.project
.settings
bin/

TODO

Expand Down
3 changes: 2 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/eclipseCodeFormatter.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"java.format.settings.url": "eclipse-formatter.xml",
"java.format.settings.profile": "Planetiler",
"java.completion.importOrder": [
"#",
""
],
"java.sources.organizeImports.staticStarThreshold": 5,
"java.sources.organizeImports.starThreshold": 999,
"java.saveActions.organizeImports": true
}
1 change: 1 addition & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ Finally, a single-threaded writer writes encoded vector tiles to the output MBTi
- Create the largest prepared statement supported by SQLite (999 parameters)
- Iterate through finished vector tile batches until the prepared statement is full, flush to disk, then repeat
- Then flush any remaining tiles at the end

71 changes: 53 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Contributing to Planetiler

Pull requests are welcome! To set up your development environment:
Pull requests are welcome! Any pull request should:

- Include at least one unit test to verify the change in behavior
- Include an end-to-end test
in [PlanetilerTests.java](planetiler-core/src/test/java/com/onthegomap/planetiler/PlanetilerTests.java)
to verify any major new user-facing features work
- Format the change `./mvnw spotless:apply` and test with `./mvnw verify` before pushing

To set up your local development environment:

- Fork the repo
- Install Java 16 or later. You can download Java manually from [Adoptium](https://adoptium.net/installation.html) or
Expand All @@ -15,30 +23,57 @@ Pull requests are welcome! To set up your development environment:
- on windows: `mvnw.cmd clean test`
- or if you already have maven installed globally on your machine: `mvn clean test`

To edit the code:
GitHub Workflows will run regression tests on any pull request.

## IDE Setup

You can use any text editor as long as you format the code and test before pushing. A good IDE will make things a lot
easier though.

### IntelliJ IDEA (recommended)

- [Install IntelliJ IDE](https://www.jetbrains.com/help/idea/installation-guide.html)
- [Install IntelliJ IDEA](https://www.jetbrains.com/help/idea/installation-guide.html)
- Install
the [Adapter for Eclipse Code Formatter plugin](https://plugins.jetbrains.com/plugin/6546-adapter-for-eclipse-code-formatter)
- In IntelliJ, click `Open`, navigate to the the `pom.xml` file in the local copy of this repo, and `Open`
then `Open as Project`
- If IntelliJ asks (and you trust the code) then click `Trust Project`
- If any java source files show "Cannot resolve symbol..." errors for Planetiler classes, you might need to
select: `File -> Invalidate Caches... -> Just Restart`.
- If you see a "Project JDK is not defined" error, then choose `Setup SDK` and point IntelliJ at the Java 16 or later
installed on your system
- Recommended: Under `Preferences -> Tools -> Actions on Save` (or `File -> Settings -> Tools -> Actions on Save` on Linux) select `Reformat code` and `Optimize imports` to
automatically format code on save.
- Under `Preferences -> Tools -> Actions on Save` (or `File -> Settings -> Tools -> Actions on Save` on Linux)
select `Reformat code` and `Optimize imports` to automatically format code on save.
- To verify everything works correctly, right click on `planetiler-core/src/test/java` folder and
click `Run 'All Tests'`

Any pull request should:
Troubleshooting:

- Include at least one unit test to verify the change in behavior
- Include an end-to-end test
in [PlanetilerTests.java](planetiler-core/src/test/java/com/onthegomap/planetiler/PlanetilerTests.java)
to verify any major new user-facing features work
- Use IntelliJ's auto-formatting for modified files (this should get enabled automatically)
- Be free of IntelliJ warnings for modified files
- If any java source files show "Cannot resolve symbol..." errors for Planetiler classes, you might need to
select: `File -> Invalidate Caches... -> Just Restart`.
- If you see a "Project JDK is not defined" error, then choose `Setup SDK` and point IntelliJ at the Java 16 or later
installed on your system

GitHub Workflows will run regression tests on any pull request.
### Visual Studio Code

- Install the [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack)
- In VSCode, click `File -> Open` and navigate to Planetiler directory
- If VSCode asks (and you trust the code) then click `Yes I trust the authors`
- To verify everything works correctly, go to the `Testing` tab and click `Run Tests`

Learn more about using VSCode with Java [here](https://code.visualstudio.com/docs/languages/java).

### Eclipse

- In [Eclipse for Java Developers](https://www.eclipse.org/downloads/packages/), click `File -> Import ...`
then `Maven -> Existing Maven Projects`, navigate to Planetiler directory, and click `Finish`
- Under `Eclipse -> Preferences...`:
- Under `Java -> Code Style -> Formatter` and choose `Import...`
choose [`eclipse-formatter.xml`](eclipse-formatter.xml) from the root of this project. Then choose `Planetiler` as
the Active profile.
- Under `Java -> Editor -> Save Actions` check `Perform selected actions on save`, `Format source code`
, `Format all lines` and `Organize imports`
- Under `Java -> Code Style -> Organize Imports` change the `number of static imports needed for .*` to 5, then remove
the groups and add 2 new groups:
- `New Static...` and `*`
- `New...` and `*`
- To verify everything works correctly, right click on `planetiler-core/src/test/java` folder and
click `Run As -> JUnit Test`

TODO: Set up checkstyle and an auto-formatter to enforce standards, so you can use any IDE.
TODO: Set up checkstyle
3 changes: 2 additions & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ Additionally, the `planetiler-basemap` module is based on [OpenMapTiles](https:/

## Data

| source | license | used as default | included in repo |
| source | license | used as default | included in repo |
|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------|-----------------|------------------|
| OpenStreetMap (OSM) data | [ODBL](https://www.openstreetmap.org/copyright) | yes | yes |
| Natural Earth | [public domain](https://www.naturalearthdata.com/about/terms-of-use/) | yes | yes |
| OSM Lakelines | [MIT](https://github.com/lukasmartinelli/osm-lakelines), data from OSM [ODBL](https://www.openstreetmap.org/copyright) | yes | no |
| OSM Water Polygons | [acknowledgement](https://osmdata.openstreetmap.de/info/license.html), data from OSM [ODBL](https://www.openstreetmap.org/copyright) | yes | yes |
| Wikidata name translations | [CCO](https://www.wikidata.org/wiki/Wikidata:Licensing) | no | no |

2 changes: 2 additions & 0 deletions PLANET.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ First decide where to get the `planet.osm.pbf` file:
- Or a [Daylight Distribution](https://daylightmap.org/) snapshot from Facebook that includes extra quality/consistency
checks, and add-ons like ML-detected roads and buildings. Combine add-ons and re-number
using [osmium-tool](https://osmcode.org/osmium-tool/):

```bash
osmium apply-changes daylight.osm.pbf admin.osc.bz2 <buildings.osc.bz2, ...> -o everything.osm.pbf
osmium renumber everything.osm.pbf -o planet.osm.pbf
```

NOTE: you need at least `admin.osc.bz2` for the `boundary` layer to show. This takes about 2.5 hours and needs as much
RAM as the `planet.osm.pbf` size.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ See the [planetiler-examples](planetiler-examples) project.

Some example runtimes (excluding downloading resources):

| Input | Profile | Machine | Time | mbtiles size | Logs |
| Input | Profile | Machine | Time | mbtiles size | Logs |
|-------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|----------------------------------------------------------|---------------------------|--------------|--------------------------------------------------------------------------------------------------------------------------------|
| s3://osm-pds/2021/planet-211011.osm.pbf (65GB) | Basemap | DO 16cpu 128GB | 3h9m cpu:42h1m avg:13.3 | 99GB | [logs](planet-logs/v0.1.0-planet-do-16cpu-128gb.txt), [VisualVM Profile](planet-logs/v0.1.0-planet-do-16cpu-128gb.nps) |
| [Daylight Distribution v1.6](https://daylightmap.org/2021/09/29/daylight-v16-released.html) with ML buildings and admin boundaries (67GB) | Basemap | DO 16cpu 128GB | 3h13m cpu:43h40m avg:13.5 | 101GB | [logs](planet-logs/v0.1.0-daylight-do-16cpu-128gb.txt) |
Expand Down
Loading