j2sdl is a complete mapping of SDL2 APIs to Java, including extension libs such as SDL_mixer, SDL_image, etc.
Add platform dependency to j2sdl-bom, followed by other required sdl2 components, for example:
dependencies {
implementation(platform('com.github.carlwilk32:j2sdl-bom:1.0-SNAPSHOT'))
implementation 'com.github.carlwilk32:j2sdl-core'
implementation 'com.github.carlwilk32:j2sdl-image'
implementation 'com.github.carlwilk32:j2sdl-mixer'
}
Provide definition for GitHub Package Repository (GPR) within your build script:
repositories {
...
maven { url 'https://ktor-github-package-registry-proxy.fly.dev' }
}
this is a custom proxy that simply redirects all the requests to GPR with Authorization header provided by default.
Q: "Why use proxy? Can't I access GPR directly?"
A: yes, you can, but...
GitHub doesn't allow anonymous read for public packages; therefore You have to issue your own Personal Access Token (PAT) and provide their repo as follows
repositories {
mavenCentral()
maven {
url = uri('https://maven.pkg.github.com/carlwilk32/*')
credentials {
username = 'YOUR_NAME'
password = 'YOUR_TOKEN'
}
}
}
This is quite annoying and barely usable approach, but there are no official solution yet.
For Maven you need to declare dependency management separately as follows
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.carlwilk32</groupId>
<artifactId>j2sdl-bom</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
And then declare required dependencies, for example:
<dependencies>
<dependency>
<groupId>com.github.carlwilk32</groupId>
<artifactId>j2sdl-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.carlwilk32</groupId>
<artifactId>j2sdl-image</artifactId>
</dependency>
</dependencies>
Additionally, you will need to provide definition for new repo to your settings.xml, for more details refere to official guide here.
This project is configured to publish all libraries to the GitHub Package Registry. To do so run
./gradlew publish
if you need to publish only specific version than you can provide a fully qualified name, like
./gradlew :j2sdl-core:publish
Read library specific README to get further details: