Skip to content

Getting started with Ashley

damios edited this page Apr 23, 2023 · 22 revisions

The first thing you will want to do is to get Ashley into your project. You have a few options depending on your environment.

Maven and Gradle

Ashley is available in Maven. The easiest way of going about this is to add the framework as a dependency of an existing Maven or Gradle project. There are two kinds of Ashley releases.

  • Official: well tested, stable packages that get released periodically. URL: https://oss.sonatype.org/content/repositories/releases
  • Snapshots: the result of nightly builds, they are more likely to break in unexpected ways. URL: https://oss.sonatype.org/content/repositories/snapshots

Maven

First, you need to add the desired repository to your pom.xml file. Change the URL depending on whether you want releases or snapshots.

	<repositories>
		<repository>
			<id>sonatype</id>
			<name>Sonatype</name>
			<url>https://oss.sonatype.org/content/repositories/releases</url>
		</repository>
	</repositories>

Then you need to add the Ashley dependency.

	<dependency>
		<groupId>com.badlogicgames.ashley</groupId>
		<artifactId>ashley</artifactId>
		<version>1.7.3</version>
	</dependency>

Gradle

Add the Maven repositories to your build.gradle file.

    repositories {
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }

Add the dependency to the dependencies element.

    dependencies {
        implementation "com.badlogicgames.ashley:ashley:1.7.3"
    }

Nightly builds

If you want the bleeding edge version of Ashley, you can get the nightly builds by using the dependency: com.badlogicgames.ashley:ashley:1.7.4-SNAPSHOT.

Working from sources

If you want the most bleeding edge version of Ashley or prefer to make your own modifications, working from sources might be the best option. Follow these steps.

  1. Install Gradle
  2. Clone the Git repository git clone [email protected]:libgdx/ashley.git
  3. Import the core and tests projects into the IDE of your choice. Using the command line is also an option.
  4. Now you can either:
  • Run the uploadArchives task and generate three jar files: bytecode, sources and javadocs. They will be in your local Maven repository.
  • Add the ashley project as a dependency to yours.

Using Ashley in a Libgdx project

If you are creating a new Libgdx project from scratch, use the gdx-setup tool and tick the Ashley checkbox.

On the other hand, if you already have a Libgdx project and want to use Ashley you need to add the appropriate repository to the `build.gradle' file as we saw in the previous section. Additionally, you will need to add the following dependencies to your projects.

	project(":core") {
		dependencies {
			implementation "com.badlogicgames.ashley:ashley:1.7.3"
		}
	}

	project(":android") {
		dependencies {
			implementation "com.badlogicgames.ashley:ashley:1.7.3"
		}
	}

	project(":html") {
		dependencies {
			implementation "com.badlogicgames.ashley:ashley:1.7.3:sources"
		}
	}

If you are targeting the browser, do not forget to update your GdxDefinition.gwt.xml and GdxDefinitionSuperdev.gwt.xml files with the proper inheritance element.

<inherits name='com.badlogic.ashley_gwt' />