Giter VIP home page Giter VIP logo

libgdx-maven-archetype's Introduction

libgdx-maven-archetype

This is a Maven archetype for creating libGDX game projects.

Installing

The archetype is not yet available via Maven Central, so you'll have to build and install it before you can use it to generate skeleton projects. Do that like so:

% git clone git://github.com/libgdx/libgdx-maven-archetype.git
% cd libgdx-maven-archetype
% mvn install

Once it's installed, you can delete the libgdx-maven-archetype directory that you checked out. You don't need it any more.

Creating a skeleton project

Creating a project using the archetype is accomplished like so:

% mvn archetype:generate \
    -DarchetypeRepository=local \
    -DarchetypeRepository=$HOME/.m2/repository \
    -DarchetypeGroupId=com.badlogic.gdx \
    -DarchetypeArtifactId=gdx-archetype \
    -DarchetypeVersion=1.2.0

This will then ask you a few questions:

  • Define value for property 'groupId': : com.mytest
  • Define value for property 'artifactId': : mygame
  • Define value for property 'version': 1.2.0: :
  • Define value for property 'package': com.mytest: :
  • Define value for property 'JavaGameClassName': : MyGame

The parts in bold above are the things we typed in. You can pick whatever you want for groupId and artifactId, though it's customary for groupId to be a reverse domain name for a domain that you own, and for artifactId to be a simple lowercase name that identifies your project.

version defaults to 1.0-SNAPSHOT but you can make it whatever you want. It's not used anywhere, and you're not going to be publishing your game via Maven, so it doesn't really matter.

package will be the main Java package for your game project, and JavaGameClassName will be the name of the Java class that is the entry point to your game. If you use the values we show above, your main class will be com.mytest.core.MyGame. The archetype puts your game code into a package named core (on top of the package you specify) because of the way the HTML backend works. You can change it later if you want, but you'll need to do some fiddling if you use the HTML backend.

Once you enter all that info, Maven will ask you to confirm your choices and then it generates your new skeleton game in a directory named whatever you specified for artifactId (in our example that's mygame).

Running your skeleton project

We'll use the names we used in the above example here, so substitute in the names you actually used.

Build and run the Desktop backend

You can build and run your game using the Desktop backend like this:

% cd mygame
% mvn integration-test -Pdesktop

This is pretty simple. It builds the Java code, and then unpacks some native libraries into the right place and then runs the code.

You can also build a single jar file version of your game that you can send to friends or do whatever you like with:

% cd mygame
% mvn package -Pdesktop
% java -jar desktop/target/mygame-desktop-1.0-SNAPSHOT-jar-with-dependencies.jar

Build and run the HTML backend

You can build and run your game using the HTML backend like this:

% cd mygame
% mvn integration-test -Phtml

This compiles the game using GWT and then runs a local web server that serves up the compiled game on http://localhost:8080. Point a web browser at that URL to test your HTML compiled game.

You can also just build the HTML version of the game so that you can copy it to a website or whatever. This is done like so:

% cd mygame
% mvn package -Phtml

This will generate your game in html/target/webapp. The important files and directories in that directory are: assets, index.html and mygame. The other cruft (META-INF and WEB-INF) you can ignore, unless you want to deploy your game as a webapp to somewhere like Google App Engine.

Build and run the Android backend

You can build your game using the Android backend and install it to a device like this:

% cd mygame
% mvn install -Pandroid

You can also easily build a signed and zipaligned APK for your Android game when you are preparing to upload it to Google Play. You need to edit your android/pom.xml and change:

    <sign.keystore>game.keystore</sign.keystore>
    <keystore.alias>game</keystore.alias>

to reflect path to your keystore file and the alias of the key you will use to sign your APK. Then you can build a signed and zipaligned APK like so:

% cd mygame
% mvn package -Pandroid -Psign -Dkeystore.password=foo

The signed and aligned APK file will be in android/target/mygame-android-aligned.apk.

Build and run the iOS backend

This assumes you have Xamarin.iOS installed, as that is currently required to build your game for iOS.

Building the iOS backend is currently TBD. Check back later!

Credits

Much of this archetype was adapted from PlayN's archetype.

libgdx-maven-archetype's People

Contributors

badlogic avatar born2snipe avatar esmann avatar fallen-s4e avatar gebeater avatar johnnyapol avatar mobidevelop avatar nimbusbp1729 avatar rblakemesser avatar samskivert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgdx-maven-archetype's Issues

Unable to generate a project

I've just try the following commande :

frederic@nostromo5:~/Projects/java/myfirstgame$ mvn archetype:generate     -DarchetypeRepository=local     -DarchetypeRepository=$HOME/.m2/repository     -DarchetypeGroupId=com.badlogic.gdx     -DarchetypeArtifactId=gdx-archetype     -DarchetypeVersion=0.9.9-SNAPSHOT

And the input the following parameters :

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Libgdx Project Archetype 0.9.9-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.0:generate (default-cli) @ gdx-archetype >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.0:generate (default-cli) @ gdx-archetype <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.0:generate (default-cli) @ gdx-archetype ---
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
[WARNING] Could not transfer metadata com.badlogic.gdx:gdx-archetype:0.9.9-SNAPSHOT/maven-metadata.xml from/to gdx-archetype-repo (/home/frederic/.m2/repository): No connector available to access repository gdx-archetype-repo (/home/frederic/.m2/repository) of type default using the available factories WagonRepositoryConnectorFactory
Define value for property 'groupId': : com.mcgivrer.games
Define value for property 'artifactId': : myfirstgame
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  com.mcgivrer.games: : 
Define value for property 'JavaGameClassName': : MyFirstGame
Confirm properties configuration:
groupId: com.mcgivrer.games
artifactId: myfirstgame
version: 1.0-SNAPSHOT
package: com.mcgivrer.games
JavaGameClassName: MyFirstGame
 Y: : Y

Then, the process crash with the following error :

[ERROR] org.apache.maven.archetype.exception.InvalidPackaging: Unable to add module to the current project as it is not of packaging type 'pom'
org.apache.maven.archetype.exception.ArchetypeGenerationFailure: org.apache.maven.archetype.exception.InvalidPackaging: Unable to add module to the current project as it is not of packaging type 'pom'
    at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.generateArchetype(DefaultFilesetArchetypeGenerator.java:237)
    at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.processFileSetArchetype(DefaultArchetypeGenerator.java:136)
    at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:106)
    at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:149)
    at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:209)
    at org.apache.maven.archetype.DefaultArchetypeManager.generateProjectFromArchetype(DefaultArchetypeManager.java:71)
    at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:190)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.archetype.exception.InvalidPackaging: Unable to add module to the current project as it is not of packaging type 'pom'
    at org.apache.maven.archetype.common.DefaultPomManager.addModule(DefaultPomManager.java:98)
    at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processPomWithParent(DefaultFilesetArchetypeGenerator.java:608)
    at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetProject(DefaultFilesetArchetypeGenerator.java:553)
    at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetModule(DefaultFilesetArchetypeGenerator.java:495)
    at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.generateArchetype(DefaultFilesetArchetypeGenerator.java:210)
    ... 27 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.383s
[INFO] Finished at: Mon Oct 21 20:56:00 CEST 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.0:generate (default-cli) on project gdx-archetype: org.apache.maven.archetype.exception.InvalidPackaging: Unable to add module to the current project as it is not of packaging type 'pom' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
frederic@nostromo5:~/Projects/java/libgdx-maven-archetype$ 

What have I done wrong ?

Maven can't resolve gdx depency.

Then I have generated maven project according to documentation. In parent pom file gdx.version is 0.9.9-SNAPSHOT. Maven can't resolve it. And I think it is an old version and needs to be changed.

Unable to generate project structure

When I run the command:
mvn archetype:generate -DarchetypeRepository=local -DarchetypeRepository=$HOME/.m2/repository -DarchetypeGroupId=com.badlogic.gdx -DarchetypeArtifactId=gdx-archetype -DarchetypeVersion=1.2.0

I get this:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.bmj:BetweenWorlds >------------------------
[INFO] Building BetweenWorlds 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ BetweenWorlds >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ BetweenWorlds <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ BetweenWorlds ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repsoitory with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
[WARNING] The POM for com:gdx-archetype:jar:1 is missing, no dependency information available
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping BetweenWorlds

[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.377 s
[INFO] Finished at: 2019-04-04T23:14:40+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project BetweenWorlds: The desired archetype does not exist (com:gdx-archetype:1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

mvn -Pandroid package fail : NoClassDefFoundError: Lorg/sonatype/aether/RepositorySystem

Hi. I'm trying to follow the wiki to setup maven project and import it to Intellj.
The desktop package goal works fine. But the android one is not working.
Here's the log

https://gist.github.com/jagt/6570775

Another issue is that when I'm trying to import it into IntelliJ the desktop profile works fine. But when I running the package goal of android profile, it complains that can't find the core module:

[ERROR] Failed to execute goal on project plasma-android: Could not resolve dependencies for project com.pre_sence.plasma:plasma-android:apk:0.0-DEV: Failure to find com.pre_sence.plasma:plasma-core:jar:0.0-DEV in https://oss.sonatype.org/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of gdx-nightlies has elapsed or updates are forced -> [Help 1]

maven commands fail with "'jar-no-fork' was specified in an execution, but not found in the plugin"

First of all, I'm not particularly familiar with the maven or the rest of the java ecosystem (i'm a python developer) so this could be a user error...

Anyways, after installing this archetype and generating an empty project, all the maven subcommands (package, integration-test, etc...) fail with the following error:

INFO] ------------------------------------------------------------------------
[INFO] Building Drop Parent
[INFO]    task-segment: [integration-test]
[INFO] ------------------------------------------------------------------------
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] ------------------------------------------------------------------------
[INFO] Building Drop Core
[INFO]    task-segment: [integration-test]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] 'jar-no-fork' was specified in an execution, but not found in the plugin
[INFO] ------------------------------------------------------------------------

I managed to resolve this by adding the maven-source-plugin to my project's pom.xml as follows:

diff --git a/pom.xml b/pom.xml
index 00d2266..c0ee2d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,6 +34,15 @@
                                        <target>1.6</target>
                                </configuration>
                        </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-source-plugin</artifactId>
+                               <version>2.2.1</version>
+                               <configuration>
+                                       <source>1.6</source>
+                                       <target>1.6</target>
+                               </configuration>
+                       </plugin>
                </plugins>
        </build>

Is this something that needs to be in src/main/resources/archetype-resources/pom.xml?

Maven skeleton generating failed

Hi. I repeat step by step instructions.
When I run
mvn archetype:generate
-DarchetypeRepository=local
-DarchetypeRepository=$HOME/.m2/repository
-DarchetypeGroupId=com.badlogic.gdx
-DarchetypeArtifactId=gdx-archetype
-DarchetypeVersion=1.2.0

I get an exception:
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2 org.apache.maven.wagon.TransferFailedException: Transfer failed for http://repo1.maven.org/maven2 501 HTTPS Required

Why it uses HTTP instead of HTTPS? I set up a profile in maven settings.xml like this:

id maven-https
activation
activeByDefault true
repositories
repository
id central
URL https://repo1.maven.org/maven2
snapshots
enabled false
pluginRepositories
pluginRepositor
id central
url https://repo1.maven.org/maven2
snapshots
enabled false

When maven asks me to choose a number:
Choose a number: 16:
What is it? I didn't found it in the readme. So next, I enter group and artefact id, version, package. It doesn't ask me to enter JavaGameClassName.

Then I get more errors. One of them:
[ERROR] Unable to add module to the current project as it is not of packaging type 'pom' org.apache.maven.archetype.old.ArchetypeTemplateProcessingException: Unable to add module to the current project as it is not of packaging type 'pom'

any help?
console_log.txt

Libgdx 0.9.8 archetype in repository

Would it be possible to push a tagged version of 0.9.8 and its archetype to your repository? If I'm building/releasing a game using Maven I'd like to be able to release using a tagged version as to avoid any possible bugs introduced in nightly builds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.