woofers / battlesnake-java-template

🐍 ‏‏‎Battlesnake starter using Gradle, GSON and Servlets 🐍

Home Page:https://play.battlesnake.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table of Contents

Battlesnake Template

A un-official Battlesnake template written in Java.

Battlesnake documentation can be found at docs.battlesnake.io.

img

About

This template is different from the official Java Battlesnake.io Template in a few ways:

  • GSON is used for JSON serialization rather than Jackson
  • Pure Java Servlets are used rather than the Spark Framework
  • Tomcat is used as the servlet container rather than Jetty which is used by default by Spark
  • Gradle is used as the build tool rather than Maven

The official Java Template is also simpler and smaller however this template comes out-of-the-box with the following additional features:

  • Logging support using Log4j2
  • Logs server response time
  • Code formatting, removing used imports using spotless

Usage

Prerequisites

  1. Install JDK 11 or higher

  2. Install Docker + Docker compose (required for Docker container method)

  3. Install Heroku CLI (required for Heroku CLI method)

  4. Install .war Heroku deployment plug-in heroku plugins:install heroku-cli-deploy ) (required for Heroku CLI method)

  5. Create a Heroku App online or using the Heroku CLI with heroku create <name>

    (alternatively any other hosting service can be used)

Test Board

Online

Goto play.battlesnake.io

Run Locally

Gradle

  1. Run the project using either ./gradle run or gradlew run for UNIX and Windows platforms respectively. This will build and run the project as a `JAR` using Webapp Runner.
  2. Use http://localhost:8080 as the snake URL.

Docker

  1. Build the project using either ./gradle build or gradlew build for UNIX and Windows platforms respectively.
  2. Run the Docker Tomcat image in a container with docker-compose up.
  3. Use http://localhost:8080/battlesnake as the snake URL.

Deployment

Heroku-GitHub Integration

  1. Go the dashboard for the Heroku app.
  2. Click on the deploy tab.
  3. Scroll down to the Deployment method and select GitHub.
  4. Enter the repository name and click Connect.

Heroku CLI

  1. Build .war file ./gradlew build
  2. Deploy to Heroku heroku war:deploy build/libs/battlesnake.war --app <name>
  3. Use https://[name].herokuapp.com/ as the snake URL.

Acknowledgments

About

🐍 ‏‏‎Battlesnake starter using Gradle, GSON and Servlets 🐍

https://play.battlesnake.com

License:GNU General Public License v3.0


Languages

Language:Java 99.3%Language:Shell 0.7%