Add template
This commit is contained in:
8
template/project.clj
Normal file
8
template/project.clj
Normal file
@@ -0,0 +1,8 @@
|
||||
(defproject play-clj/lein-template "0.1.0-SNAPSHOT"
|
||||
:description "A template for making play-clj projects"
|
||||
:url "https://github.com/oakes/play-clj"
|
||||
:license {:name "Public Domain"
|
||||
:url "http://unlicense.org/UNLICENSE"}
|
||||
:dependencies [[lein-droid "0.2.0"]]
|
||||
:resource-paths ["resources"]
|
||||
:eval-in-leiningen true)
|
||||
BIN
template/resources/armeabi-libgdx.so
Normal file
BIN
template/resources/armeabi-libgdx.so
Normal file
Binary file not shown.
BIN
template/resources/armeabi-v7a-libgdx.so
Normal file
BIN
template/resources/armeabi-v7a-libgdx.so
Normal file
Binary file not shown.
BIN
template/resources/libObjectAL.a
Normal file
BIN
template/resources/libObjectAL.a
Normal file
Binary file not shown.
BIN
template/resources/libgdx.a
Normal file
BIN
template/resources/libgdx.a
Normal file
Binary file not shown.
BIN
template/resources/x86-libgdx.so
Normal file
BIN
template/resources/x86-libgdx.so
Normal file
Binary file not shown.
96
template/src/leiningen/new/play_clj.clj
Normal file
96
template/src/leiningen/new/play_clj.clj
Normal file
@@ -0,0 +1,96 @@
|
||||
(ns leiningen.new.play-clj
|
||||
(:require [clojure.java.io :as io]
|
||||
[leiningen.droid.new :as droid-new]
|
||||
[leiningen.new.templates :as t]))
|
||||
|
||||
(defn play-clj
|
||||
[name & [package-name]]
|
||||
(let [render (t/renderer "play-clj")
|
||||
lein-droid-render (droid-new/renderer "templates")
|
||||
desktop-class-name "desktop-launcher"
|
||||
android-class-name "AndroidLauncher"
|
||||
ios-class-name "IOSLauncher"
|
||||
package-name (t/sanitize (t/multi-segment (or package-name name)))
|
||||
package-prefix (->> (.lastIndexOf package-name ".")
|
||||
(subs package-name 0))
|
||||
main-ns (t/sanitize-ns package-name)
|
||||
desktop-ns (str main-ns "." desktop-class-name)
|
||||
android-ns (str package-name "." android-class-name)
|
||||
ios-ns (str package-name "." ios-class-name)
|
||||
data {:app-name name
|
||||
:name (t/project-name name)
|
||||
:package package-name
|
||||
:package-sanitized package-name
|
||||
:package-prefix package-prefix
|
||||
:desktop-class-name desktop-class-name
|
||||
:android-class-name android-class-name
|
||||
:ios-class-name ios-class-name
|
||||
:activity android-class-name
|
||||
:namespace main-ns
|
||||
:desktop-namespace desktop-ns
|
||||
:android-namespace android-ns
|
||||
:ios-namespace ios-ns
|
||||
:path (t/name-to-path main-ns)
|
||||
:desktop-path (t/name-to-path desktop-ns)
|
||||
:android-path (t/name-to-path android-ns)
|
||||
:ios-path (t/name-to-path ios-ns)
|
||||
:year (t/year)
|
||||
:target-sdk "15"}]
|
||||
(t/->files data
|
||||
; main
|
||||
["README.md" (render "README.md" data)]
|
||||
[".gitignore" (render "gitignore" data)]
|
||||
; desktop
|
||||
["desktop/project.clj" (render "desktop-project.clj" data)]
|
||||
["desktop/src-common/{{path}}.clj" (render "core.clj" data)]
|
||||
["desktop/src/{{desktop-path}}.clj"
|
||||
(render "desktop-launcher.clj" data)]
|
||||
"desktop/src-common"
|
||||
"desktop/src"
|
||||
"desktop/resources"
|
||||
; android
|
||||
["android/project.clj"
|
||||
(render "android-project.clj" data)]
|
||||
["android/src/java/{{android-path}}.java"
|
||||
(render "AndroidLauncher.java" data)]
|
||||
"android/src/clojure"
|
||||
["android/AndroidManifest.xml"
|
||||
(lein-droid-render "AndroidManifest.xml" data)]
|
||||
["android/res/drawable-hdpi/ic_launcher.png"
|
||||
(lein-droid-render "ic_launcher_hdpi.png")]
|
||||
["android/res/drawable-mdpi/ic_launcher.png"
|
||||
(lein-droid-render "ic_launcher_mdpi.png")]
|
||||
["android/res/drawable-ldpi/ic_launcher.png"
|
||||
(lein-droid-render "ic_launcher_ldpi.png")]
|
||||
["android/res/values/strings.xml"
|
||||
(lein-droid-render "strings.xml" data)]
|
||||
["android/res/drawable-hdpi/splash_circle.png"
|
||||
(lein-droid-render "splash_circle.png")]
|
||||
["android/res/drawable-hdpi/splash_droid.png"
|
||||
(lein-droid-render "splash_droid.png")]
|
||||
["android/res/drawable-hdpi/splash_hands.png"
|
||||
(lein-droid-render "splash_hands.png")]
|
||||
["android/res/drawable/splash_background.xml"
|
||||
(lein-droid-render "splash_background.xml")]
|
||||
["android/res/anim/splash_rotation.xml"
|
||||
(lein-droid-render "splash_rotation.xml")]
|
||||
["android/res/layout/splashscreen.xml"
|
||||
(lein-droid-render "splashscreen.xml")]
|
||||
["android/src/java/{{path}}/SplashActivity.java"
|
||||
(lein-droid-render "SplashActivity.java" data)]
|
||||
["android/libs/armeabi/libgdx.so"
|
||||
(-> (io/resource "armeabi-libgdx.so") io/input-stream)]
|
||||
["android/libs/armeabi-v7a/libgdx.so"
|
||||
(-> (io/resource "armeabi-v7a-libgdx.so") io/input-stream)]
|
||||
["android/libs/x86/libgdx.so"
|
||||
(-> (io/resource "x86-libgdx.so") io/input-stream)]
|
||||
; ios
|
||||
["ios/project.clj" (render "ios-project.clj" data)]
|
||||
["ios/Info.plist.xml" (render "Info.plist.xml" data)]
|
||||
"ios/src/clojure"
|
||||
["ios/src/java/{{ios-path}}.java"
|
||||
(render "IOSLauncher.java" data)]
|
||||
["ios/libs/libObjectAL.a"
|
||||
(-> (io/resource "libObjectAL.a") io/input-stream)]
|
||||
["ios/libs/libgdx.a"
|
||||
(-> (io/resource "libgdx.a") io/input-stream)])))
|
||||
20
template/src/leiningen/new/play_clj/AndroidLauncher.java
Normal file
20
template/src/leiningen/new/play_clj/AndroidLauncher.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package {{package}};
|
||||
|
||||
import clojure.lang.RT;
|
||||
import clojure.lang.Symbol;
|
||||
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import com.badlogic.gdx.Game;
|
||||
|
||||
public class {{android-class-name}} extends AndroidApplication {
|
||||
public void onCreate (android.os.Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("{{namespace}}"));
|
||||
try {
|
||||
Game game = (Game) RT.var("{{namespace}}", "{{app-name}}").deref();
|
||||
initialize(game, true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
31
template/src/leiningen/new/play_clj/IOSLauncher.java
Normal file
31
template/src/leiningen/new/play_clj/IOSLauncher.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package {{package}};
|
||||
|
||||
import clojure.lang.RT;
|
||||
import clojure.lang.Symbol;
|
||||
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
|
||||
import com.badlogic.gdx.Game;
|
||||
|
||||
import org.robovm.cocoatouch.foundation.NSAutoreleasePool;
|
||||
import org.robovm.cocoatouch.uikit.UIApplication;
|
||||
|
||||
public class {{ios-class-name}} extends IOSApplication.Delegate {
|
||||
protected IOSApplication createApplication() {
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("{{namespace}}"));
|
||||
try {
|
||||
Game game = (Game) RT.var("{{namespace}}", "{{app-name}}").deref();
|
||||
return new IOSApplication(game, config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
NSAutoreleasePool pool = new NSAutoreleasePool();
|
||||
UIApplication.main(argv, null, {{ios-class-name}}.class);
|
||||
pool.drain();
|
||||
}
|
||||
}
|
||||
61
template/src/leiningen/new/play_clj/Info.plist.xml
Normal file
61
template/src/leiningen/new/play_clj/Info.plist.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>{{app-name}}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{{app-name}}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>{{package}}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>{{app-name}}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${app.version}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>CFBundleIcons</key>
|
||||
<dict>
|
||||
<key>CFBundlePrimaryIcon</key>
|
||||
<dict>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon</string>
|
||||
<string>Icon-72</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
11
template/src/leiningen/new/play_clj/README.md
Normal file
11
template/src/leiningen/new/play_clj/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# {{name}}
|
||||
|
||||
A LibGDX game in which ... well, that part is up to you.
|
||||
|
||||
## Contents
|
||||
|
||||
* `android/src` Android-specific code
|
||||
* `desktop/resources` Images, audio, and other files
|
||||
* `desktop/src` Desktop-specific code
|
||||
* `desktop/src-common` Cross-platform game code
|
||||
* `ios/src` iOS-specific code
|
||||
37
template/src/leiningen/new/play_clj/android-project.clj
Normal file
37
template/src/leiningen/new/play_clj/android-project.clj
Normal file
@@ -0,0 +1,37 @@
|
||||
(defproject {{app-name}} "0.0.1-SNAPSHOT"
|
||||
:description "FIXME: write description"
|
||||
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "0.9.9" :use-resources true]
|
||||
[com.badlogicgames.gdx/gdx-backend-android "0.9.9"]
|
||||
[neko/neko "3.0.0"]
|
||||
[org.clojure-android/clojure "1.5.1-jb" :use-resources true]
|
||||
[play-clj "0.1.0-SNAPSHOT"]]
|
||||
:repositories [["sonatype"
|
||||
"https://oss.sonatype.org/content/repositories/snapshots/"]]
|
||||
:profiles {:dev {:dependencies [[android/tools.nrepl "0.2.0-bigstack"]
|
||||
[compliment "0.0.3"]]
|
||||
:android {:aot :all-with-unused}}
|
||||
:release {:android
|
||||
{;; Specify the path to your private
|
||||
;; keystore and the the alias of the
|
||||
;; key you want to sign APKs with.
|
||||
;; :keystore-path "/home/user/.android/private.keystore"
|
||||
;; :key-alias "mykeyalias"
|
||||
:aot :all}}}
|
||||
|
||||
:android {;; Specify the path to the Android SDK directory either
|
||||
;; here or in your ~/.lein/profiles.clj file.
|
||||
;; :sdk-path "/home/user/path/to/android-sdk/"
|
||||
|
||||
;; Uncomment this if dexer fails with OutOfMemoryException
|
||||
;; :force-dex-optimize true
|
||||
|
||||
:assets-path "../desktop/resources"
|
||||
:native-libraries-paths ["libs"]
|
||||
:target-version "{{target-sdk}}"
|
||||
:aot-exclude-ns ["clojure.parallel" "clojure.core.reducers"]
|
||||
:dex-opts ["-JXmx2048M"]}
|
||||
|
||||
:source-paths ["src/clojure" "../desktop/src-common"]
|
||||
:java-source-paths ["src/java" "gen"]
|
||||
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"])
|
||||
18
template/src/leiningen/new/play_clj/core.clj
Normal file
18
template/src/leiningen/new/play_clj/core.clj
Normal file
@@ -0,0 +1,18 @@
|
||||
(ns {{namespace}}
|
||||
(:require [play-clj.core :refer :all]
|
||||
[play-clj.ui :refer :all]))
|
||||
|
||||
(defscreen main-screen
|
||||
:on-show
|
||||
(fn [screen entities]
|
||||
(update! screen :renderer (stage))
|
||||
(conj entities (label "Hello world!" (color :white))))
|
||||
:on-render
|
||||
(fn [screen entities]
|
||||
(clear!)
|
||||
(render! screen entities)))
|
||||
|
||||
(defgame {{app-name}}
|
||||
:on-create
|
||||
(fn [this]
|
||||
(set-screen! this main-screen)))
|
||||
10
template/src/leiningen/new/play_clj/desktop-launcher.clj
Normal file
10
template/src/leiningen/new/play_clj/desktop-launcher.clj
Normal file
@@ -0,0 +1,10 @@
|
||||
(ns {{desktop-namespace}}
|
||||
(:require [{{namespace}} :refer :all])
|
||||
(:import [com.badlogic.gdx.backends.lwjgl LwjglApplication]
|
||||
[org.lwjgl.input Keyboard])
|
||||
(:gen-class))
|
||||
|
||||
(defn -main
|
||||
[]
|
||||
(LwjglApplication. {{app-name}} "{{app-name}}" 800 600 true)
|
||||
(Keyboard/enableRepeatEvents true))
|
||||
16
template/src/leiningen/new/play_clj/desktop-project.clj
Normal file
16
template/src/leiningen/new/play_clj/desktop-project.clj
Normal file
@@ -0,0 +1,16 @@
|
||||
(defproject {{app-name}} "0.0.1-SNAPSHOT"
|
||||
:description "FIXME: write description"
|
||||
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "0.9.9"]
|
||||
[com.badlogicgames.gdx/gdx-backend-lwjgl "0.9.9"]
|
||||
[com.badlogicgames.gdx/gdx-platform "0.9.9"
|
||||
:classifier "natives-desktop"]
|
||||
[org.clojure/clojure "1.5.1"]
|
||||
[play-clj "0.1.0-SNAPSHOT"]]
|
||||
:repositories [["sonatype"
|
||||
"https://oss.sonatype.org/content/repositories/snapshots/"]]
|
||||
|
||||
:source-paths ["src" "src-common"]
|
||||
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
|
||||
:aot [{{desktop-namespace}}]
|
||||
:main {{desktop-namespace}})
|
||||
12
template/src/leiningen/new/play_clj/gitignore
Normal file
12
template/src/leiningen/new/play_clj/gitignore
Normal file
@@ -0,0 +1,12 @@
|
||||
/target
|
||||
/lib
|
||||
/classes
|
||||
/checkouts
|
||||
pom.xml
|
||||
pom.xml.asc
|
||||
*.jar
|
||||
*.class
|
||||
.lein-deps-sum
|
||||
.lein-failures
|
||||
.lein-plugins
|
||||
.lein-repl-history
|
||||
17
template/src/leiningen/new/play_clj/ios-project.clj
Normal file
17
template/src/leiningen/new/play_clj/ios-project.clj
Normal file
@@ -0,0 +1,17 @@
|
||||
(defproject {{app-name}} "0.0.1-SNAPSHOT"
|
||||
:description "FIXME: write description"
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "0.9.9"]
|
||||
[com.badlogicgames.gdx/gdx-backend-robovm "0.9.9"]
|
||||
[org.clojure/clojure "1.5.1"]
|
||||
[play-clj "0.1.0-SNAPSHOT"]]
|
||||
:repositories [["sonatype"
|
||||
"https://oss.sonatype.org/content/repositories/snapshots/"]]
|
||||
:source-paths ["src/clojure" "../desktop/src-common"]
|
||||
:java-source-paths ["src/java"]
|
||||
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
|
||||
:ios {:robovm-opts ["-forcelinkclasses" "{{package-prefix}}.**:clojure.**:com.badlogic.**:play_clj.**"
|
||||
"-libs" "libs/libObjectAL.a:libs/libgdx.a"
|
||||
"-frameworks" "UIKit:OpenGLES:QuartzCore:CoreGraphics:OpenAL:AudioToolbox:AVFoundation"
|
||||
"-resources" "../desktop/resources/**"]}
|
||||
:aot :all
|
||||
:main {{ios-namespace}})
|
||||
Reference in New Issue
Block a user