Skip to content

Commit

Permalink
Add Discord project and notes about Spring Boot
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonBailey committed Jun 12, 2024
1 parent 4ef6c57 commit e0bf2f3
Show file tree
Hide file tree
Showing 8 changed files with 779 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
// TODO Look more into this https://docs.gradle.org/8.8/userguide/publishing_maven.html#publishing_maven:resolved_dependencies
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
}
Expand Down
661 changes: 661 additions & 0 deletions discord/LICENSE

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions discord/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Discord "server-as-code"

I was thinking recently that Discord servers must have some JSON config representing the entire
config of the server, but it seems like they don't. I thought to myself that it would be nice to
be able to set them up like infrastructure in [Terraform][1]. Thus, this project was born. I put
the title in quotes because "server-as-code" sounds like some sort of "serverless" thing (like
[Lambda][2]), but I mean it in the way Discord uses the term. Which is essentially to refer to a
group of chat rooms. If you know Discord, then you know what a server refers to and I'm not going to
waste my time explaining it lol. That said, I do know that the Discord API calls them "guilds" so
things will probably get a little confusing. (Especially considering [Guilds][3] are a new feature).

## Notes

I am going to use Spring Boot's [Dependency Management Plugin][4] instead of trying to use the
platform project (`:platform`) in this project. I am doing this because:

1. Many examples of Spring Boot use this plugin so it's easier to follow along.
2. I think I may have really messed something up with the platform project. When I bring it in with
`implementation(...)` instead of `api(...)` it is also bringing in all the dependencies. I
vaguely remember this being a problem with the Vexilum project, but it didn't actually break
anything, but now it's causing problems with logback and the simple-slf4j loggers both being on
the path.
3. The entire reason I even made the `:platform` project here was because I wanted to see what
Gradle's own dependency management tools were like in comparison to the plugin Spring Boot
offers, but it's really only been a hassle and led to me doing even more wacky things. (For
example, see the mess of `if (requested.id.id == ...)` to try and do this with plugins.) It also
looks like Gradle may have added more ways to do version catalogs since I originally looked into
it. I'd like to start over from scratch with it, but I don't want to waste time troubleshooting
that and lose my muse to work on this project.

## Look into

To reproduce the error below, remove the `versionMapping` section in `java-common-conventions`
plugin. I blindly followed what a link in the error told me without understanding.

```
* What went wrong:
Execution failed for task ':discord:generateMetadataFileForMavenJavaPublication'.
> Invalid publication 'mavenJava':
- Publication only contains dependencies and/or constraints without a version. You should add
minimal version information, publish resolved versions (For more on this, please refer to
https://docs.gradle.org/8.8/userguide/publishing_maven.html#publishing_maven:resolved_dependencies
in the Gradle documentation.) or reference a platform (For more platforms, please refer to
https://docs.gradle.org/8.8/userguide/platforms.html in the Gradle documentation.). Disable
this check by adding 'dependencies-without-versions' to the suppressed validations of the
:discord:generateMetadataFileForMavenJavaPublication task.
```

[1]: https://www.terraform.io/
[2]: https://aws.amazon.com/lambda/
[3]: https://support.discord.com/hc/en-us/articles/23187611406999-Guilds-FAQ
[4]: https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/
29 changes: 29 additions & 0 deletions discord/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
id("dev.jacksonbailey.wheel.java-application-conventions")
id("dev.jacksonbailey.wheel.shut-up-javadoc")
id("io.spring.dependency-management") version "1.1.5"
id("org.springframework.boot") version "3.3.0"
}

// Even though this is just for one project, it might be nice to extract it out somewhere later
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:3.3.0")
}
dependencies {
dependency("org.jetbrains:annotations:24.1.0")
}
}

dependencies {
compileOnly("org.jetbrains:annotations")
implementation("org.springframework.boot:spring-boot")
implementation("org.springframework.boot:spring-boot-autoconfigure")
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework:spring-context")
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
2 changes: 2 additions & 0 deletions discord/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
licenseName=AGPL-3.0-or-later
licenseUrl=https://www.gnu.org/licenses/agpl-3.0.txt
13 changes: 13 additions & 0 deletions discord/src/main/java/dev/jacksonbailey/wheel/discord/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dev.jacksonbailey.wheel.discord;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Main {

public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dev.jacksonbailey.wheel.discord;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class MainTest {

@Test
void contextLoads() {}

}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ rootProject.name = "wheel"

include(
"collections",
"discord",
"platform",
"vexillum",
"vexillum:vexillum-api",
Expand Down

0 comments on commit e0bf2f3

Please sign in to comment.