在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):libgdx/libgdx-gradle-template开源软件地址(OpenSource Url):https://github.com/libgdx/libgdx-gradle-template开源编程语言(OpenSource Language):Shell 54.6%开源软件介绍(OpenSource Introduction):libgdx-gradle-templateNotice Jan-14-2014This incarnation of the Gradle Template is no longer under active development. Further work is being done in the main libgdx project/repo. If you'd like to contribute, you'll find development being done inside of the extensions module. Gradle template for libgdx projects that works on the CLI, Eclipse and Intellij IDEA. This tempate will eventually replace the libgdx Setup-UI currently in use. To get started Download the template or fork and clone this repository. A word about GradleGradle is a nifty build and dependency managment system. A build system allows you to easily compile and package (potentially different versions of) your project. A dependency management system allows you to declaratively specify 3rd party libraries, which the dependency management system will pull in automatically for you. No need to put Jar files or native libraries in your project tree. You do not need to install Gradle manually, this template uses the Gradle wrapper which takes care of that for you transparently. The first time you invoke gradle on the command line, the Gradle wrapper will automatically download and install Gradle into your home directory. To use this template you do not need to know Gradle necessarily, pretty much everything is taken care of for you. A word about Source ControlThe contents of this repository are everything you need to commit to your source control repository. Do not commit Eclipse or IntelliJ Idea projec files, especially if other people are working on the same project. Instead, everyone just downloads this IDE-unaware project, then uses Gradle to generate local IDE project files. Also make sure to commit the gradlew, gradlew.bat files and the gradle/ folder. This way, nobody needs to manually install Gradle on their system. Project StructureThis template has the following structure (ignoring some directores and files in the Android project for brevity).
Command Line UsageBefore you can do anything, you need to set the ANDROID_HOME environment variable to point to your Android SDK's root folder. On Windows you can do this on the command line
On Linux and Mac OS X you can do this in the shell
Both commands will set the ANDROID_HOME enviroment variable for the duration of your shell session. You should set this environment variable permanently on your system. Please consult the internet for instructions. Once you have ANDROID_HOME set, you can continue with using Gradle. On windows, you use the gradlew.bat files, which you can invoke like this:
On Linux or Mac OS X you invoke gradle like this:
Note the leading dot slash on Unix like systems. In both cases, the clean task will remove all build files, e.g. class files previously generated. Running the desktop projectTo run the desktop project issue this gradle command:
Packaging the desktop projectTo create a ZIP distribution including shell scripts to start your app, issue this gradle command:
This will create a ZIP file in the folder desktop/build/distributions, ready to be send to testers. Running the Android projectTo run the Android project, issues this gradle command:
This will compile the APK for Android, and install it on a connected device. You will have to start the app manually on the device. Packaging the Android projectThe android:installDebug task will create an unsigned debug APK of your app, which you can find in the android/build/apk/ folder. If you want to build a signed APK for release on the Google Play Store, please consult the Android Gradle plugin documentation Eclipse UsageYou can let Gradle generate Eclipse projects for your application easily:
Once Gradle is done, delete the .project file in the root directory of the project. This is a little glitch that will get resolved shorty. Now you can import the projects into Eclipse
Running/Debugging in EclipseTo run/debug the desktop project:
To run/debug the Android project:
Intellij Idea UsageYou can let Gradle generate Intellij Idea project for your application easily:
Once Gradle is done, you can open the projects in Intellij Idea:
You'll need to set the Android SDK on the Android module before continuing:
Running/Debugging in Intellij IdeaTo run/debug the desktop project, first create a run configuration:
To run/debug the desktop project, just select the run configuration you just created and then either click the green play button, or the green play button with the bug. To run/debug the Android project, first create a run configuration:
To run/debug the desktop project, just select the run configuration you just created and then either click the green play button, or the green play button with the bug. Dependency ManagementOne of the benefits of Gradle and similar systems like Maven or Ivy, is that integrating third party dependencies in your project is really simple. It also has the benfit that your project file tree doesn't contain any JAR files or other 3rd party resources, keeping things clean and tidy. Every time your or a team mate invoke a Gradle task, the dependencies of your project will get checked and updated if necessary. How and where do you specify dependencies? TBD see build.gradle in root for now |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论