Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions bom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CommandsAPI BOM (Bill of Materials)

This module provides a BOM (Bill of Materials) for CommandsAPI, making it easier to manage consistent versions across all CommandsAPI modules.

## Usage

### Gradle (Kotlin DSL)

```kotlin
dependencies {
// Import the BOM
implementation(platform("fr.traqueur.commands:bom:VERSION"))

// Then add dependencies without specifying versions
implementation("fr.traqueur.commands:core")
implementation("fr.traqueur.commands:platform-spigot")
implementation("fr.traqueur.commands:platform-velocity")
implementation("fr.traqueur.commands:platform-jda")
implementation("fr.traqueur.commands:annotations-addon")
}
```

### Gradle (Groovy DSL)

```groovy
dependencies {
// Import the BOM
implementation platform('fr.traqueur.commands:bom:VERSION')

// Then add dependencies without specifying versions
implementation 'fr.traqueur.commands:core'
implementation 'fr.traqueur.commands:platform-spigot'
implementation 'fr.traqueur.commands:platform-velocity'
implementation 'fr.traqueur.commands:platform-jda'
implementation 'fr.traqueur.commands:annotations-addon'
}
```

### Maven

```xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>fr.traqueur.commands</groupId>
<artifactId>bom</artifactId>
<version>VERSION</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- Then add dependencies without specifying versions -->
<dependency>
<groupId>fr.traqueur.commands</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>fr.traqueur.commands</groupId>
<artifactId>platform-spigot</artifactId>
</dependency>
<dependency>
<groupId>fr.traqueur.commands</groupId>
<artifactId>platform-velocity</artifactId>
</dependency>
<dependency>
<groupId>fr.traqueur.commands</groupId>
<artifactId>platform-jda</artifactId>
</dependency>
<dependency>
<groupId>fr.traqueur.commands</groupId>
<artifactId>annotations-addon</artifactId>
</dependency>
</dependencies>
```

## Benefits

Using the BOM provides several advantages:

1. **Version Consistency**: All CommandsAPI modules will use compatible versions
2. **Simplified Dependency Management**: No need to specify versions for each module
3. **Easier Updates**: Update all modules by changing only the BOM version
4. **Reduced Conflicts**: Ensures all modules work together correctly

## Available Modules

The BOM manages versions for the following modules:

- `core` - Core functionality and API
- `platform-spigot` - Spigot/Bukkit platform support
- `platform-velocity` - Velocity proxy platform support
- `platform-jda` - JDA (Discord) platform support
- `annotations-addon` - Annotation-based command registration
77 changes: 77 additions & 0 deletions bom/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
plugins {
id 'java-platform'
id 'maven-publish'
}

description = 'CommandsAPI BOM (Bill of Materials)'

javaPlatform {
allowDependencies()
}

dependencies {
constraints {
api(project(':core'))
api(project(':spigot'))
api(project(':velocity'))
api(project(':jda'))
api(project(':annotations-addon'))
}
}

publishing {
repositories {
maven {
def repository = System.getProperty('repository.name', 'snapshots')
def repoType = repository.toLowerCase()

name = "groupez${repository.capitalize()}"
url = uri("https://repo.groupez.dev/${repoType}")

credentials {
username = findProperty("${name}Username") ?: System.getenv('MAVEN_USERNAME')
password = findProperty("${name}Password") ?: System.getenv('MAVEN_PASSWORD')
}

authentication {
create("basic", BasicAuthentication)
}
}
}

publications {
create('maven', MavenPublication) {
from components.javaPlatform

groupId = rootProject.group.toString()
artifactId = 'bom'
version = rootProject.version.toString()

pom {
name = 'CommandsAPI BOM'
description = 'CommandsAPI Bill of Materials - Manages consistent versions across CommandsAPI modules'
url = 'https://github.com/Traqueur-dev/CommandsAPI'

licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}

developers {
developer {
id = 'traqueur'
name = 'Traqueur'
}
}

scm {
connection = 'scm:git:git://github.com/Traqueur-dev/CommandsAPI.git'
developerConnection = 'scm:git:ssh://github.com/Traqueur-dev/CommandsAPI.git'
url = 'https://github.com/Traqueur-dev/CommandsAPI'
}
}
}
}
}
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ allprojects {
group = 'fr.traqueur.commands'
version = property('version')

apply {
plugin 'java-library'
if (project.name != 'bom') {
apply {
plugin 'java-library'
}
}

ext.classifier = System.getProperty('archive.classifier')
Expand All @@ -27,7 +29,7 @@ allprojects {
}

subprojects {
if (project.name.contains('test-')) {
if (project.name.contains('test-') || project.name == 'bom') {
return;
}

Expand Down
11 changes: 10 additions & 1 deletion core/src/main/java/fr/traqueur/commands/api/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void unregisterCommand(Command<T, S> command, boolean subcommands) {
* @param <C> The type of the argument.
*/
public <C> void registerConverter(Class<C> typeClass, ArgumentConverter<C> converter) {
this.typeConverters.put(typeClass.getSimpleName().toLowerCase(), new ArgumentConverter.Wrapper<>(typeClass, converter));
this.typeConverters.put(typeClass.getName().toLowerCase(), new ArgumentConverter.Wrapper<>(typeClass, converter));
}

/**
Expand Down Expand Up @@ -465,9 +465,18 @@ public CommandInvoker<T, S> getInvoker() {
*/
private void registerInternalConverters() {
this.registerConverter(String.class, (s) -> s);

// Register both primitive and wrapper types for DefaultArgumentParser (Spigot/Velocity).
// JDA's ArgumentParser handles primitives internally, but text-based platforms need explicit registration.
// Wrapper types (Integer.class, Long.class, etc.) are registered for compatibility with wrapper usage.
// Primitive types (int.class, long.class, etc.) are registered to support primitive method parameters.
this.registerConverter(Boolean.class, new BooleanArgument<>());
this.registerConverter(boolean.class, new BooleanArgument<>());
this.registerConverter(Integer.class, new IntegerArgument());
this.registerConverter(int.class, new IntegerArgument());
this.registerConverter(Double.class, new DoubleArgument());
this.registerConverter(double.class, new DoubleArgument());
this.registerConverter(Long.class, new LongArgument());
this.registerConverter(long.class, new LongArgument());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ record Simple(Class<?> clazz) implements ArgumentType {

@Override
public String key() {
return clazz.getSimpleName().toLowerCase();
return clazz.getName().toLowerCase();
}

}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=5.0.0
version=5.0.1
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rootProject.name = 'CommandsAPI'

include 'bom'
include 'velocity-test-plugin'
include 'spigot-test-plugin'
include 'spigot'
Expand Down
Loading