OSDN Git Service

added new setup tool based on gradle
authorbadlogic <badlogicgames@gmail.com>
Sat, 5 Oct 2013 13:31:02 +0000 (15:31 +0200)
committerbadlogic <badlogicgames@gmail.com>
Sat, 5 Oct 2013 13:31:02 +0000 (15:31 +0200)
28 files changed:
extensions/gdx-setup/.classpath [new file with mode: 0644]
extensions/gdx-setup/.project [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/GdxSetup.java [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/Project.java [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/ProjectFile.java [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/AndroidManifest.xml [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/assets/badlogic.jpg [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/build.gradle [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/ic_launcher-web.png [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/proguard-project.txt [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/project.properties [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-hdpi/ic_launcher.png [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-mdpi/ic_launcher.png [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xhdpi/ic_launcher.png [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xxhdpi/ic_launcher.png [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/values/strings.xml [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/values/styles.xml [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/src/AndroidLauncher [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/build.gradle [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/core/build.gradle [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/core/src/MainClass [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/desktop/build.gradle [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/desktop/src/DesktopLauncher [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.jar [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.properties [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradlew [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradlew.bat [new file with mode: 0644]
extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/settings.gradle [new file with mode: 0644]

diff --git a/extensions/gdx-setup/.classpath b/extensions/gdx-setup/.classpath
new file mode 100644 (file)
index 0000000..fb50116
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extensions/gdx-setup/.project b/extensions/gdx-setup/.project
new file mode 100644 (file)
index 0000000..9148643
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>gdx-setup</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/GdxSetup.java b/extensions/gdx-setup/src/com/badlogic/gdx/setup/GdxSetup.java
new file mode 100644 (file)
index 0000000..07e06da
--- /dev/null
@@ -0,0 +1,175 @@
+package com.badlogic.gdx.setup;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Command line tool to generate libgdx projects
+ * @author badlogic
+ *
+ */
+public class GdxSetup {
+       public void build (String outputDir, String appName, String packageName, String mainClass) {
+               Project project = new Project();
+               
+               String packageDir = packageName.replace('.', '/');
+               
+               // root dir/gradle files
+               project.files.add(new ProjectFile("build.gradle"));
+               project.files.add(new ProjectFile("settings.gradle"));
+               project.files.add(new ProjectFile("gradlew", false));
+               project.files.add(new ProjectFile("gradlew.bat", false));
+               project.files.add(new ProjectFile("gradle/wrapper/gradle-wrapper.jar", false));
+               project.files.add(new ProjectFile("gradle/wrapper/gradle-wrapper.properties", false));
+               
+               // core project
+               project.files.add(new ProjectFile("core/build.gradle"));
+               project.files.add(new ProjectFile("core/src/MainClass", "core/src/" + packageDir + "/" + mainClass + ".java", true));
+               
+               // desktop project
+               project.files.add(new ProjectFile("desktop/build.gradle"));
+               project.files.add(new ProjectFile("desktop/src/DesktopLauncher", "desktop/src/" + packageDir + "/desktop/DesktopLauncher.java", true));
+               
+               // android project
+               project.files.add(new ProjectFile("android/assets/badlogic.jpg", false));
+               project.files.add(new ProjectFile("android/res/values/strings.xml", false));
+               project.files.add(new ProjectFile("android/res/values/styles.xml", false));
+               project.files.add(new ProjectFile("android/res/drawable-hdpi/ic_launcher.png", false));
+               project.files.add(new ProjectFile("android/res/drawable-mdpi/ic_launcher.png", false));
+               project.files.add(new ProjectFile("android/res/drawable-xhdpi/ic_launcher.png", false));
+               project.files.add(new ProjectFile("android/res/drawable-xxhdpi/ic_launcher.png", false));
+               project.files.add(new ProjectFile("android/src/AndroidLauncher", "android/src/" + packageDir + "/android/AndroidLauncher.java", true));
+               project.files.add(new ProjectFile("android/AndroidManifest.xml"));
+               project.files.add(new ProjectFile("android/build.gradle"));
+               project.files.add(new ProjectFile("android/ic_launcher-web.png", false));
+               project.files.add(new ProjectFile("android/proguard-project.txt", false));
+               project.files.add(new ProjectFile("android/project.properties", false));
+               
+               Map<String, String> values = new HashMap<String, String>();
+               values.put("%APP_NAME%", appName);
+               values.put("%PACKAGE%", packageName);
+               values.put("%MAIN_CLASS%", mainClass);
+               
+               copyAndReplace(outputDir, project, values);
+       }
+
+       private void copyAndReplace (String outputDir, Project project, Map<String, String> values) {
+               File out = new File(outputDir);
+               if(!out.exists() && !out.mkdirs()) {
+                       throw new RuntimeException("Couldn't create output directory '" + out.getAbsolutePath() + "'");
+               }
+               
+               for(ProjectFile file: project.files) {
+                       copyFile(file, out, values);
+               }
+       }
+       
+       private byte[] readResource(String resource) {
+               InputStream in = null;
+               try {
+                       ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+                       byte[] buffer = new byte[1024*10];
+                       in = GdxSetup.class.getResourceAsStream("/com/badlogic/gdx/setup/resources/" + resource);
+                       if(in == null) throw new RuntimeException("Couldn't read resource '" + resource + "'");
+                       int read = 0;
+                       while((read = in.read(buffer)) > 0) {
+                               bytes.write(buffer, 0, read);
+                       }
+                       return bytes.toByteArray();
+               } catch(IOException e) {
+                       throw new RuntimeException("Couldn't read resource '" + resource + "'", e);
+               } finally {
+                       if(in != null) try { in.close(); } catch(IOException e) {}
+               }
+       }
+       
+       private String readResourceAsString(String resource) {
+               try {
+                       return new String(readResource(resource), "UTF-8");
+               } catch (UnsupportedEncodingException e) {
+                       throw new RuntimeException(e);
+               }
+       }
+       
+       private void writeFile (File outFile, byte[] bytes) {
+               OutputStream out = null;
+               
+               try {
+                       out = new BufferedOutputStream(new FileOutputStream(outFile));
+                       out.write(bytes);
+               } catch(IOException e) {
+                       throw new RuntimeException("Couldn't write file '" + outFile.getAbsolutePath() + "'", e);
+               } finally {
+                       if(out != null) try { out.close(); } catch(IOException e) {}
+               }
+       }
+       
+       private void writeFile(File outFile, String text) {
+               try {
+                       writeFile(outFile, text.getBytes("UTF-8"));
+               } catch (UnsupportedEncodingException e) {
+                       throw new RuntimeException(e);
+               }
+       }
+
+       private void copyFile(ProjectFile file, File out, Map<String, String> values) {
+               File outFile = new File(out, file.outputName);
+               if(!outFile.getParentFile().exists() && !outFile.getParentFile().mkdirs()) {
+                       throw new RuntimeException("Couldn't create dir '" + outFile.getAbsolutePath() + "'");
+               }
+               
+               if(file.isTemplate) {
+                       String txt = readResourceAsString(file.resourceName);
+                       txt = replace(txt, values);
+                       writeFile(outFile, txt);
+               } else {
+                       writeFile(outFile, readResource(file.resourceName));
+               }
+       }
+
+       private String replace (String txt, Map<String, String> values) {
+               for(String key: values.keySet()) {
+                       String value = values.get(key);
+                       txt = txt.replace(key, value);
+               }
+               return txt;
+       }
+       
+       private static void printHelp() {
+               System.out.println("Usage: GdxSetup --dir <dir-name> --name <app-name> --package <package> --mainClass <mainClass>");
+       }
+       
+       private static Map<String, String> parseArgs(String[] args) {
+               if(args.length % 2 != 0) {
+                       printHelp();
+                       System.exit(-1);
+               }
+               
+               Map<String, String> params = new HashMap<String, String>();
+               for(int i = 0; i < args.length; i+=2) {
+                       String param = args[i].replace("--", "");
+                       String value = args[i+1];
+                       params.put(param, value);
+               }
+               return params;
+       }
+       
+       public static void main (String[] args) {
+               Map<String, String> params = parseArgs(args);
+               if(!params.containsKey("dir") || !params.containsKey("name") || !params.containsKey("package") || !params.containsKey("mainClass")) {
+                       printHelp();
+                       System.exit(-1);
+               }
+               
+               new GdxSetup().build(params.get("dir"), params.get("name"), params.get("package"), params.get("mainClass"));
+       }
+}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/Project.java b/extensions/gdx-setup/src/com/badlogic/gdx/setup/Project.java
new file mode 100644 (file)
index 0000000..99c6e09
--- /dev/null
@@ -0,0 +1,17 @@
+package com.badlogic.gdx.setup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Describes all the files required to generate a
+ * new project for an Application. Files are found
+ * on the classpath of the gdx-setup project, see
+ * package com.badlogic.gdx.setup.resources.
+ * @author badlogic
+ *
+ */
+public class Project {
+       /** list of files, relative to project directory **/
+       public List<ProjectFile> files = new ArrayList<ProjectFile>();
+}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/ProjectFile.java b/extensions/gdx-setup/src/com/badlogic/gdx/setup/ProjectFile.java
new file mode 100644 (file)
index 0000000..18fd965
--- /dev/null
@@ -0,0 +1,36 @@
+package com.badlogic.gdx.setup;
+
+/**
+ * A file in a {@link Project}, the resourceName specifies the location
+ * of the template file, the outputName specifies the final name of the
+ * file relative to its project, the isTemplate field specifies if 
+ * values need to be replaced in this file or not.
+ * @author badlogic
+ *
+ */
+public class ProjectFile {
+       /** the name of the template resource, relative to com.badlogic.gdx.setup.resources **/
+       public String resourceName;
+       /** the name of the output file, including directories, relative to the project dir **/
+       public String outputName;
+       /** whehter to replace values in this file **/
+       public boolean isTemplate;
+       
+       public ProjectFile(String name) {
+               this.resourceName = name;
+               this.outputName = name;
+               this.isTemplate = true;
+       }
+       
+       public ProjectFile(String name, boolean isTemplate) {
+               this.resourceName = name;
+               this.outputName = name;
+               this.isTemplate = isTemplate;
+       }
+       
+       public ProjectFile(String resourceName, String outputName, boolean isTemplate) {
+               this.resourceName = resourceName;
+               this.outputName = outputName;
+               this.isTemplate = isTemplate;           
+       }
+}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/AndroidManifest.xml b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..3f05992
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.badlogicgames.gradletest"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name="%PACKAGE%.android.AndroidLauncher"
+            android:label="@string/app_name" 
+            android:screenOrientation="landscape"
+            android:configChanges="keyboard|keyboardHidden|orientation">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/assets/badlogic.jpg b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/assets/badlogic.jpg
new file mode 100644 (file)
index 0000000..4390da6
Binary files /dev/null and b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/assets/badlogic.jpg differ
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/build.gradle b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/build.gradle
new file mode 100644 (file)
index 0000000..772d01c
--- /dev/null
@@ -0,0 +1,96 @@
+android {
+    buildToolsVersion "17.0"
+    compileSdkVersion 17
+    sourceSets {
+        main {
+            manifest.srcFile 'AndroidManifest.xml'
+            java.srcDirs = ['src']
+            resources.srcDirs = ['src']
+            aidl.srcDirs = ['src']
+            renderscript.srcDirs = ['src']
+            res.srcDirs = ['res']
+            assets.srcDirs = ['assets']
+        }
+
+        instrumentTest.setRoot('tests')
+    }
+}
+
+// needed to add JNI shared libraries to APK when compiling on CLI
+tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
+    println pkgTask
+    pkgTask.jniDir new File(projectDir, 'libs')
+}
+
+// called every time gradle gets executed, takes the native dependencies of
+// the natives configuration, and extracts them to the proper libs/ folders
+// so they get packed with the APK.
+task copyAndroidNatives() { 
+    file("libs/armeabi/").mkdirs();
+    file("libs/armeabi-v7a/").mkdirs();
+    file("libs/x86/").mkdirs();
+
+    configurations.natives.files.each { jar ->
+        def outputDir = null
+        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
+        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
+        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")                  
+        if(outputDir != null) {            
+            copy { from zipTree(file(jar)).matching { include "*.so" } into outputDir }
+        }
+    }
+}
+
+// sets up the Android Eclipse project, using the old Ant based build.
+eclipse {
+    // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
+    // ignores any nodes added in classpath.file.withXml
+    sourceSets {
+        main {
+            java.srcDirs "src", 'gen'
+        }
+    }
+
+    jdt {
+        sourceCompatibility = 1.6
+        targetCompatibility = 1.6
+    }
+
+    classpath {
+        plusConfigurations += project.configurations.compile        
+        containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'       
+    }
+
+    project {
+        name = appName + "-android"
+        natures 'com.android.ide.eclipse.adt.AndroidNature'
+        buildCommands.clear();
+        buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
+        buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
+        buildCommand "org.eclipse.jdt.core.javabuilder"
+        buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
+    }
+}
+
+// sets up the Android Idea project, using the old Ant based build.
+idea {
+    module {
+        sourceDirs += file("src");
+        scopes = [ COMPILE: [plus:[project.configurations.compile]]]        
+
+        iml {
+            withXml {
+                def node = it.asNode()
+                def builder = NodeBuilder.newInstance();
+                builder.current = node;
+                builder.component(name: "FacetManager") {
+                    facet(type: "android", name: "Android") {
+                        configuration {
+                            option(name: "UPDATE_PROPERTY_FILES", value:"true")
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/ic_launcher-web.png b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/ic_launcher-web.png
new file mode 100644 (file)
index 0000000..a18cbb4
Binary files /dev/null and b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/ic_launcher-web.png differ
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/proguard-project.txt b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/proguard-project.txt
new file mode 100644 (file)
index 0000000..f2fe155
--- /dev/null
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/project.properties b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/project.properties
new file mode 100644 (file)
index 0000000..ce39f2d
--- /dev/null
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-18
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-hdpi/ic_launcher.png b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-hdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..288b665
Binary files /dev/null and b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-hdpi/ic_launcher.png differ
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-mdpi/ic_launcher.png b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-mdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..6ae570b
Binary files /dev/null and b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-mdpi/ic_launcher.png differ
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xhdpi/ic_launcher.png b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..d4fb7cd
Binary files /dev/null and b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xxhdpi/ic_launcher.png b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..85a6081
Binary files /dev/null and b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/values/strings.xml b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/values/strings.xml
new file mode 100644 (file)
index 0000000..71947b8
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">%APP_NAME%</string>
+
+</resources>
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/values/styles.xml b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/res/values/styles.xml
new file mode 100644 (file)
index 0000000..467e355
--- /dev/null
@@ -0,0 +1,14 @@
+<resources>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="android:Theme">
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+               <item name="android:windowIsTranslucent">true</item>
+               <item name="android:windowBackground">@android:color/transparent</item>
+               <item name="android:windowContentOverlay">@null</item>
+               <item name="android:windowNoTitle">true</item>
+               <item name="android:windowIsFloating">false</item>
+               <item name="android:backgroundDimEnabled">false</item>
+    </style>
+
+</resources>
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/src/AndroidLauncher b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/src/AndroidLauncher
new file mode 100644 (file)
index 0000000..28f1637
--- /dev/null
@@ -0,0 +1,16 @@
+package %PACKAGE%.android;
+
+import android.os.Bundle;
+
+import com.badlogic.gdx.backends.android.AndroidApplication;
+import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
+import %PACKAGE%.%MAIN_CLASS%;
+
+public class AndroidLauncher extends AndroidApplication {
+       @Override
+       protected void onCreate (Bundle savedInstanceState) {
+               super.onCreate(savedInstanceState);
+               AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
+               initialize(new %MAIN_CLASS%(), config);
+       }
+}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/build.gradle b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/build.gradle
new file mode 100644 (file)
index 0000000..3a8c8d0
--- /dev/null
@@ -0,0 +1,55 @@
+buildscript {
+    repositories { mavenCentral() }
+    dependencies { classpath 'com.android.tools.build:gradle:0.5.+' }
+}
+
+allprojects {
+    apply plugin: "eclipse"
+    apply plugin: "idea"
+    
+    version = "1.0"
+    ext.appName = "%APP_NAME%"
+    ext.gdxVersion = "0.9.9-SNAPSHOT"
+    
+    repositories {
+        mavenCentral()
+        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
+        mavenLocal();
+    }
+}
+
+project(":core") {
+    apply plugin: "java"
+    
+    dependencies {
+        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
+    }
+}
+
+project(":desktop") {
+    apply plugin: "java"
+    apply plugin: "application"
+    
+    dependencies {
+        compile project(":core")
+        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
+        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
+    }
+}
+
+project(":android") {
+    apply plugin: "android"
+
+    configurations { natives }
+
+    dependencies {
+        compile project(":core")
+        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"        
+        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
+        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
+    }
+}
+
+tasks.eclipse.doLast {
+       delete ".project"
+}
\ No newline at end of file
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/core/build.gradle b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/core/build.gradle
new file mode 100644 (file)
index 0000000..9daa508
--- /dev/null
@@ -0,0 +1,13 @@
+apply plugin: "java"
+
+sourceCompatibility = 1.6
+
+dependencies {
+    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
+}
+
+sourceSets.main.java.srcDirs = [ "src/" ]
+
+eclipse.project {
+    name = appName
+}
\ No newline at end of file
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/core/src/MainClass b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/core/src/MainClass
new file mode 100644 (file)
index 0000000..52a3f16
--- /dev/null
@@ -0,0 +1,27 @@
+package %PACKAGE%;
+
+import com.badlogic.gdx.ApplicationAdapter;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
+
+public class %MAIN_CLASS% extends ApplicationAdapter {
+       SpriteBatch batch;
+       Texture img;
+       
+       @Override
+       public void create () {
+               batch = new SpriteBatch();
+               img = new Texture("badlogic.jpg");
+       }
+
+       @Override
+       public void render () {
+               Gdx.gl.glClearColor(1, 0, 0, 1);
+               Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+               batch.begin();
+               batch.draw(img, 0, 0);
+               batch.end();
+       }
+}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/desktop/build.gradle b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/desktop/build.gradle
new file mode 100644 (file)
index 0000000..ab51e84
--- /dev/null
@@ -0,0 +1,16 @@
+apply plugin: "java"
+apply plugin: "application"
+
+sourceCompatibility = 1.6
+mainClassName = "%PACKAGE%.desktop.DesktopLauncher"
+sourceSets.main.java.srcDirs = [ "src/" ]
+sourceSets.main.resources.srcDirs = [file("../android/assets").getAbsolutePath()]
+
+// idea doesn't like relative paths outside of content root...
+tasks.ideaModule.doFirst {
+       sourceSets.main.resources.srcDirs = [] 
+}
+
+eclipse.project {
+    name = appName + "-desktop"
+}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/desktop/src/DesktopLauncher b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/desktop/src/DesktopLauncher
new file mode 100644 (file)
index 0000000..a155a65
--- /dev/null
@@ -0,0 +1,12 @@
+package %PACKAGE%.desktop;
+
+import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
+import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
+import %PACKAGE%.%MAIN_CLASS%;
+
+public class DesktopLauncher {
+       public static void main (String[] arg) {
+               LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
+               new LwjglApplication(new %MAIN_CLASS%(), config);
+       }
+}
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.jar b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.jar
new file mode 100644 (file)
index 0000000..b979729
Binary files /dev/null and b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.properties b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.properties
new file mode 100644 (file)
index 0000000..387ff5e
--- /dev/null
@@ -0,0 +1,6 @@
+#Sat Sep 21 13:08:26 CEST 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradlew b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradlew
new file mode 100644 (file)
index 0000000..91a7e26
--- /dev/null
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradlew.bat b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradlew.bat
new file mode 100644 (file)
index 0000000..aec9973
--- /dev/null
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off\r
+@rem ##########################################################################\r
+@rem\r
+@rem  Gradle startup script for Windows\r
+@rem\r
+@rem ##########################################################################\r
+\r
+@rem Set local scope for the variables with windows NT shell\r
+if "%OS%"=="Windows_NT" setlocal\r
+\r
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r
+set DEFAULT_JVM_OPTS=\r
+\r
+set DIRNAME=%~dp0\r
+if "%DIRNAME%" == "" set DIRNAME=.\r
+set APP_BASE_NAME=%~n0\r
+set APP_HOME=%DIRNAME%\r
+\r
+@rem Find java.exe\r
+if defined JAVA_HOME goto findJavaFromJavaHome\r
+\r
+set JAVA_EXE=java.exe\r
+%JAVA_EXE% -version >NUL 2>&1\r
+if "%ERRORLEVEL%" == "0" goto init\r
+\r
+echo.\r
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r
+echo.\r
+echo Please set the JAVA_HOME variable in your environment to match the\r
+echo location of your Java installation.\r
+\r
+goto fail\r
+\r
+:findJavaFromJavaHome\r
+set JAVA_HOME=%JAVA_HOME:"=%\r
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe\r
+\r
+if exist "%JAVA_EXE%" goto init\r
+\r
+echo.\r
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r
+echo.\r
+echo Please set the JAVA_HOME variable in your environment to match the\r
+echo location of your Java installation.\r
+\r
+goto fail\r
+\r
+:init\r
+@rem Get command-line arguments, handling Windowz variants\r
+\r
+if not "%OS%" == "Windows_NT" goto win9xME_args\r
+if "%@eval[2+2]" == "4" goto 4NT_args\r
+\r
+:win9xME_args\r
+@rem Slurp the command line arguments.\r
+set CMD_LINE_ARGS=\r
+set _SKIP=2\r
+\r
+:win9xME_args_slurp\r
+if "x%~1" == "x" goto execute\r
+\r
+set CMD_LINE_ARGS=%*\r
+goto execute\r
+\r
+:4NT_args\r
+@rem Get arguments from the 4NT Shell from JP Software\r
+set CMD_LINE_ARGS=%$\r
+\r
+:execute\r
+@rem Setup the command line\r
+\r
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar\r
+\r
+@rem Execute Gradle\r
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r
+\r
+:end\r
+@rem End local scope for the variables with windows NT shell\r
+if "%ERRORLEVEL%"=="0" goto mainEnd\r
+\r
+:fail\r
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r
+rem the _cmd.exe /c_ return code!\r
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1\r
+exit /b 1\r
+\r
+:mainEnd\r
+if "%OS%"=="Windows_NT" endlocal\r
+\r
+:omega\r
diff --git a/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/settings.gradle b/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/settings.gradle
new file mode 100644 (file)
index 0000000..ba685ed
--- /dev/null
@@ -0,0 +1 @@
+include "core", "desktop", "android"
\ No newline at end of file