From 7892b2492be5916962f0f965327b9e4bc7f7b403 Mon Sep 17 00:00:00 2001 From: Chris Molozian Date: Fri, 4 Aug 2017 01:43:22 +0100 Subject: [PATCH] Initial build setup. --- .gitignore | 297 ++++++++++++++++++ .gitmodules | 3 + README.md | 4 + build.gradle | 97 ++++++ server | 1 + settings.gradle | 0 .../java/com/heroiclabs/nakama/Client.java | 20 ++ .../com/heroiclabs/nakama/DefaultClient.java | 44 +++ .../heroiclabs/nakama/DefaultClientTest.java | 31 ++ 9 files changed, 497 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.md create mode 100644 build.gradle create mode 160000 server create mode 100644 settings.gradle create mode 100644 src/main/java/com/heroiclabs/nakama/Client.java create mode 100644 src/main/java/com/heroiclabs/nakama/DefaultClient.java create mode 100644 src/test/java/com/heroiclabs/nakama/DefaultClientTest.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3707107 --- /dev/null +++ b/.gitignore @@ -0,0 +1,297 @@ +# Created by https://www.gitignore.io/api/git,java,macos,linux,gradle,eclipse,windows,sublimetext,intellij+all,intellij+iml + +### Eclipse ### + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +### Git ### +*.orig + +### Intellij+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### Intellij+all Patch ### +# Ignores the whole idea folder +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# The out folder may also exist in sub directories +# In GitHub's .gitignore, it is only excluded at the top level +out/ + +### Intellij+iml ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: + +# Sensitive or high-churn files: + +# Gradle: + +# CMake + +# Mongo Explorer plugin: + +## File-based project format: + +## Plugin-specific files: + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +### Intellij+iml Patch ### +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### SublimeText ### +# cache files for sublime text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# workspace files are user-specific +*.sublime-workspace + +# project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using SublimeText +# *.sublime-project + +# sftp configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Gradle ### +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +# End of https://www.gitignore.io/api/git,java,macos,linux,gradle,eclipse,windows,sublimetext,intellij+all,intellij+iml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e6249db --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "server"] + path = server + url = git@github.com:heroiclabs/nakama.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..f0d89a5 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Nakama Java +=========== + +> Android optimised Java client for Nakama server. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f3b4f6a --- /dev/null +++ b/build.gradle @@ -0,0 +1,97 @@ +/* + * Copyright 2017 Heroic Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' + } +} + +plugins { + id 'com.google.protobuf' version '0.8.2' + id 'java' + id 'idea' +} + +apply plugin: 'com.github.johnrengelman.shadow' + +group = 'com.heroiclabs.nakama' +version = '0.1.0' + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +dependencies { + compileOnly 'org.projectlombok:lombok:1.16.18' + compile 'com.google.code.gson:gson:2.8.1' + compile 'com.google.protobuf:protobuf-lite:3.0.1' + compile 'com.squareup.okhttp3:okhttp:3.8.1' + compile 'org.slf4j:slf4j-api:1.7.25' + testCompile 'junit:junit:4.12' +} + +idea { + module { + sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java"); + } +} + +jar { + manifest { + attributes 'Implementation-Title': 'Nakama client', + 'Implementation-Version': version + } +} + +protobuf { + generateProtoTasks { + all().each { task -> + task.builtins { + remove java // Don't generate a copy with "protobuf-java". + } + task.plugins { + javalite { // Must activate "javalite" plugin. + } + } + } + } + plugins { + javalite { + artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0' + } + } + protoc { + artifact = 'com.google.protobuf:protoc:3.3.0' + } +} + +repositories { + mavenCentral() +} + +shadowJar { +} + +sourceSets { + main { + proto { + srcDir "$projectDir/server/server" + } + } +} diff --git a/server b/server new file mode 160000 index 0000000..5314e51 --- /dev/null +++ b/server @@ -0,0 +1 @@ +Subproject commit 5314e519fe00c947283fdf4576aba7abbeaef317 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/heroiclabs/nakama/Client.java b/src/main/java/com/heroiclabs/nakama/Client.java new file mode 100644 index 0000000..f2a75d4 --- /dev/null +++ b/src/main/java/com/heroiclabs/nakama/Client.java @@ -0,0 +1,20 @@ +/* + * Copyright 2017 The Nakama Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.heroiclabs.nakama; + +public interface Client { +} diff --git a/src/main/java/com/heroiclabs/nakama/DefaultClient.java b/src/main/java/com/heroiclabs/nakama/DefaultClient.java new file mode 100644 index 0000000..05c766b --- /dev/null +++ b/src/main/java/com/heroiclabs/nakama/DefaultClient.java @@ -0,0 +1,44 @@ +/* + * Copyright 2017 The Nakama Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.heroiclabs.nakama; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public class DefaultClient implements Client { + + private final String serverKey; + + public static DefaultClient defaults(String serverKey) { + return builder(serverKey).build(); + } + + public static Builder builder(String serverKey) { + return new Builder(serverKey); + } + + @RequiredArgsConstructor + public static class Builder { + private final String serverKey; + + public DefaultClient build() { + return new DefaultClient(serverKey); + } + + } +} diff --git a/src/test/java/com/heroiclabs/nakama/DefaultClientTest.java b/src/test/java/com/heroiclabs/nakama/DefaultClientTest.java new file mode 100644 index 0000000..73d5f8e --- /dev/null +++ b/src/test/java/com/heroiclabs/nakama/DefaultClientTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2017 The Nakama Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.heroiclabs.nakama; + +import org.junit.Assert; +import org.junit.Test; + +public final class DefaultClientTest { + + @Test + public void builderTest() { + Client client = DefaultClient.builder("defaultkey").build(); + + Assert.assertNotNull(client); + } + +}