diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 134c0a6..c0a2c63 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -7,22 +7,23 @@ jobs: # Set up the OS runs-on: ubuntu-latest env: - # Nexus credentials and GitHub token - NEXUS_USERNAME: '${{ secrets.NEXUS_USERNAME }}' - NEXUS_PASSWORD: '${{ secrets.NEXUS_PASSWORD }}' + # Sonatype Credentials & GitHub token + SONATYPE_USERNAME: '${{ secrets.SONATYPE_USERNAME }}' + SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASSWORD }}' GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' # Set environment - env: 'prod' + ENV: 'prod' + PROJECT_NAME: 'TranslationsModule' steps: # Checkout the Code - name: Checkout Code uses: actions/checkout@v3 # Set up git hashes environment variables - name: Git Hashes - uses: Im-Fran/git-hashes-action@v1.0.0 + uses: Im-Fran/git-hashes-action@v1.0.3 # Set up version from tag environment variables - name: Version from Tag Action - uses: Im-Fran/version-from-tag-action@v1.0.1 + uses: Im-Fran/version-from-tag-action@v1.0.3 with: remove-first-character: 'v' # Set up the JDK @@ -31,27 +32,30 @@ jobs: with: distribution: adopt java-version: 11 + cache: 'gradle' # Make gradle executable - name: Make gradle executable run: chmod +x gradlew # Clean, Test, Publish and Build (in that order to save the artifact to the action) - name: Test, Deploy and Build with Gradle - run: ./gradlew clean test publish shadow dokkaHtml + run: ./gradlew clean test shadowJar dokkaHtml publish publishToSonatype closeAndReleaseSonatypeStagingRepository -no-daemon # Now we store the artifact in the action - name: Upload the artifact uses: actions/upload-artifact@v3 with: - name: TranslationsModule - path: ./build/libs/TranslationsModule-${{ env.VERSION }}.jar + name: ${{ env.PROJECT_NAME }} + path: ./build/libs/${{ env.PROJECT_NAME }}-${{ env.VERSION }}.jar # Here we upload the binary to the release - name: Upload to release uses: JasonEtco/upload-to-release@master with: - args: ./build/libs/TranslationsModule-${{ env.VERSION }}.jar application/java-archive + args: ./build/libs/${{ env.PROJECT_NAME }}-${{ env.VERSION }}.jar application/java-archive # Now we deploy the documents to GitHub pages - name: Deploy Dokka uses: JamesIves/github-pages-deploy-action@v4.4.1 with: branch: gh-pages folder: build/dokka - clean: true \ No newline at end of file + clean: true + clean-exclude: | + CNAME diff --git a/.github/workflows/gradle-test.yml b/.github/workflows/gradle-test.yml index f9e1e13..e2bcf6e 100644 --- a/.github/workflows/gradle-test.yml +++ b/.github/workflows/gradle-test.yml @@ -1,6 +1,6 @@ name: "Test" # Only execute this workflow when a PR is opened or when something is pushed to the master branch -on: [push, pull_request] +on: [pull_request] jobs: testBuilds: strategy: @@ -12,20 +12,21 @@ jobs: runs-on: ubuntu-latest # Set up environment variables env: - env: 'local' # Set to local, so it won't deploy the jar to the repos + ENV: 'local' # Set to local, so it won't deploy the jar to the repos steps: - # Checkout code - - name: Checkout Code - uses: actions/checkout@v3 - # Setup java and maven - - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v3 - with: - distribution: adopt - java-version: ${{ matrix.java-version }} - # Setup executable gradle - - name: Make Gradle executable - run: chmod +x gradlew - # Test building without dokka - - name: Build Jar with Java ${{ matrix.java-version }} - run: ./gradlew clean publish shadow -x dokkaHtml \ No newline at end of file + # Checkout code + - name: Checkout Code + uses: actions/checkout@v3 + # Setup java and maven + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v3 + with: + distribution: adopt + java-version: ${{ matrix.java-version }} + cache: 'gradle' + # Setup executable gradle + - name: Make Gradle executable + run: chmod +x gradlew + # Test building without dokka + - name: Build Jar with Java ${{ matrix.java-version }} + run: ./gradlew clean shadowJar test -x dokkaHtml -no-daemon \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 27e35c1..8b3e501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,26 @@ -# v0.1.6 - Snapshot +## v0.2.0 - Snapshot +* Added sonatype +* Added gradle kotlin dsl +* Updated workflows +* Updated dependencies +* Updated README.md + +## v0.1.6 - Snapshot * Updated depends * Moved to JitCI * Improve testing to avoid unwanted files committed -# v0.1.5 - Snapshot +## v0.1.5 - Snapshot * Now translations are automatically colorized (unless you set `colorize` to `false`) * Updated tests -# v0.1.4 - Snapshot +## v0.1.4 - Snapshot * Updated SimpleCoreAPI to v0.3.0-SNAPSHOT * Now the TranslationManager is initialized at the load stage of the module * Added GitHub Repository option for AutoUpdater -# v0.1.3 - Snapshot +## v0.1.3 - Snapshot * Moved Translation from objects/ * Added new register methods to TranslationManager * Added mainColor to Translation @@ -22,11 +29,11 @@ module * Created new Tests (TranslationColorTest.kt and TranslationTest.kt) * Now the Jar is automatically uploaded to the release! -# v0.1.2 - Snapshots +## v0.1.2 - Snapshots * Fixed dependency FilesModule -# v0.1.1 - Snapshot +## v0.1.1 - Snapshot * Updated Dependencies -# v0.1.0 - Snapshot +## v0.1.0 - Snapshot Hello, World! diff --git a/README.md b/README.md index 0beac7b..b009168 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![](https://jitci.com/gh/TheProgramSrc/SimpleCore-TranslationsModule/svg)](https://jitci.com/gh/TheProgramSrc/SimpleCore-TranslationsModule) [![](https://jitpack.io/v/xyz.theprogramsrc/SimpleCore-TranslationsModule.svg)](https://jitpack.io/#xyz.theprogramsrc/SimpleCore-TranslationsModule) +[![](https://img.shields.io/nexus/s/xyz.theprogramsrc/translationsmodule?server=https%3A%2F%2Fs01.oss.sonatype.org)]() # SimpleCore-TranslationsModule Translations module for SimpleCore API. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 9c16e1f..0000000 --- a/build.gradle +++ /dev/null @@ -1,119 +0,0 @@ -plugins { - id 'org.jetbrains.kotlin.jvm' version '1.7.20' - id 'maven-publish' - id 'com.github.johnrengelman.shadow' version '7.1.2' - id 'cl.franciscosolis.blossom-extended' version '1.3.1' - id 'org.jetbrains.dokka' version '1.7.20' -} - -def projectVersion = (System.getenv("VERSION") ?: '0.1.6-SNAPSHOT').replaceFirst("v", "").replace('/', '') - -group 'xyz.theprogramsrc' -version projectVersion -description 'Translations module for SimpleCore API.' - -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://repo.theprogramsrc.xyz/repository/maven-public/' } - maven { url 'https://repo.theprogramsrc.xyz/repository/simplecoreapi-modules/' } - maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } - maven { url 'https://oss.sonatype.org/content/repositories/releases/' } - maven { url 'https://oss.sonatype.org/content/groups/public/' } - maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } - maven { url 'https://repo.codemc.org/repository/maven-public/' } - maven { url 'https://jitpack.io/' } -} - -dependencies { - compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.7.20' - compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT' - compileOnly 'net.md-5:bungeecord-api:1.18-R0.1-SNAPSHOT' - compileOnly 'xyz.theprogramsrc:simplecoreapi:0.3.1-SNAPSHOT' - compileOnly 'xyz.theprogramsrc:filesmodule:0.1.1-SNAPSHOT' - - testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1' -} - -shadowJar { - mergeServiceFiles() - exclude('**/*.kotlin_metadata') - exclude('**/*.kotlin_builtins') - - archiveBaseName.set('TranslationsModule') - archiveClassifier.set('') -} - -test { - useJUnitPlatform() -} - -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - withSourcesJar() -} - -blossom { - replaceToken '@name@', rootProject.name - replaceToken '@version@', project.version.toString() - replaceToken '@description@', project.description - replaceToken '@git_short@', System.getenv("GIT_COMMIT_SHORT_HASH") ?: "unknown" - replaceToken '@git_full@', System.getenv("GIT_COMMIT_LONG_HASH") ?: "unknown" -} - -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' -} - -tasks.withType(Copy) { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - -tasks.withType(Jar) { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - -configurations { - testImplementation { - extendsFrom(compileOnly) - } -} - -tasks.named("dokkaHtml") { - outputDirectory.set(file(project.buildDir.absolutePath + '/dokka')) -} - -publishing { - repositories { - if(System.getenv('env') == 'prod'){ - maven { - name = 'GitHubPackages' - url = 'https://maven.pkg.github.com/TheProgramSrc/SimpleCore-TranslationsModule' - credentials { - username = System.getenv('GITHUB_ACTOR') - password = System.getenv('GITHUB_TOKEN') - } - } - }else{ - mavenLocal() - } - } - publications { - mavenKotlin(MavenPublication) { publication -> - artifactId = 'translationsmodule' - - from components.java - - pom.withXml { - asNode().appendNode('packaging', 'jar') - if(asNode().get('dependencies')[0] != null) { - asNode().remove(asNode().get('dependencies')[0]) - } - } - } - } -} - -publish.dependsOn clean, test, jar, shadowJar diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..fe73bc2 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,184 @@ +import com.github.jengelman.gradle.plugins.shadow.ShadowExtension +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + `maven-publish` + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id("com.github.johnrengelman.shadow") version "7.1.2" + id("cl.franciscosolis.blossom-extended") version "1.3.1" + + kotlin("jvm") version "1.8.10" + id("org.jetbrains.dokka") version "1.7.20" +} + +val env = project.rootProject.file(".env").let { file -> + if(file.exists()) file.readLines().filter { it.isNotBlank() && !it.startsWith("#") && it.split("=").size == 2 }.associate { it.split("=")[0] to it.split("=")[1] } else emptyMap() +}.toMutableMap().apply { putAll(System.getenv()) } + +val projectVersion = env["VERSION"] ?: "0.2.0-SNAPSHOT" + +group = "xyz.theprogramsrc" +version = projectVersion +description = "Translations module for SimpleCore API." + +repositories { + mavenLocal() + mavenCentral() + + maven("https://s01.oss.sonatype.org/content/groups/public/") + maven("https://oss.sonatype.org/content/groups/public/") + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + maven("https://repo.codemc.org/repository/maven-public/") + maven("https://jitpack.io/") +} + +dependencies { + compileOnly("xyz.theprogramsrc:simplecoreapi:0.6.2-SNAPSHOT") + compileOnly("xyz.theprogramsrc:filesmodule:0.2.0-SNAPSHOT") + + compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT") + compileOnly("net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT") + + testImplementation("org.junit.jupiter:junit-jupiter:5.9.2") +} + + +tasks { + named("shadowJar") { + mergeServiceFiles() + exclude("**/*.kotlin_metadata") + exclude("**/*.kotlin_builtins") + + archiveBaseName.set(rootProject.name) + archiveClassifier.set("") + } + + test { + useJUnitPlatform() + } + + java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + withSourcesJar() + withJavadocJar() + } + + compileKotlin { + kotlinOptions { + jvmTarget = "11" + } + } + + compileTestKotlin { + kotlinOptions { + jvmTarget = "11" + } + } + + compileJava { + options.encoding = "UTF-8" + } + + jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + } + + copy { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + } + + dokkaHtml { + val dokkaFolder = file(project.buildDir.absolutePath + "/dokka") + outputDirectory.set(dokkaFolder) + + } +} + +configurations { + testImplementation { + extendsFrom(configurations.compileOnly.get()) + } +} + +val dokkaJavadocJar by tasks.register("dokkaJavadocJar") { + dependsOn(tasks.dokkaJavadoc, tasks.dokkaHtml) + from(tasks.dokkaJavadoc.flatMap { it.outputDirectory }) + archiveClassifier.set("javadoc") +} + +publishing { + repositories { + if (env["ENV"] == "prod") { + if (env.containsKey("GITHUB_ACTOR") && env.containsKey("GITHUB_TOKEN")) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/TheProgramSrc/SimpleCore-${rootProject.name}") + credentials { + username = env["GITHUB_ACTOR"] + password = env["GITHUB_TOKEN"] + } + } + } + } else { + mavenLocal() + } + } + + publications { + create("shadow") { + project.extensions.configure { + artifactId = rootProject.name.lowercase() + + component(this@create) + artifact(dokkaJavadocJar) + artifact(tasks.kotlinSourcesJar) + + pom { + name.set(rootProject.name) + description.set(project.description) + url.set("https://github.com/TheProgramSrc/SimpleCore-${rootProject.name}") + + licenses { + license { + name.set("GNU GPL v3") + url.set("https://github.com/TheProgramSrc/SimpleCore-${rootProject.name}/blob/master/LICENSE") + } + } + + developers { + developer { + id.set("ImFran") + name.set("Francisco Solis") + email.set("imfran@duck.com") + } + } + + scm { + url.set("https://github.com/TheProgramSrc/SimpleCore-${rootProject.name}") + } + } + } + } + } +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + + username.set(env["SONATYPE_USERNAME"]) + password.set(env["SONATYPE_PASSWORD"]) + } + } +} + +tasks.withType { + dependsOn(tasks.test, tasks.kotlinSourcesJar, dokkaJavadocJar, tasks.jar, tasks.shadowJar) +} + +tasks.withType { + dependsOn(tasks.test, tasks.kotlinSourcesJar, tasks.jar, dokkaJavadocJar, tasks.shadowJar) +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..35d2cc9 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..ccebba7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..42defcc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..79a61d4 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/gradlew.bat b/gradlew.bat index f127cfd..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e39af41..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'TranslationsModule' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..e10c7be --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "TranslationsModule" diff --git a/src/main/resources/module.properties b/src/main/resources/module.properties index 53fd1d9..c87efec 100644 --- a/src/main/resources/module.properties +++ b/src/main/resources/module.properties @@ -3,6 +3,5 @@ name=TranslationsModule description=@description@ version=@version@ author=TheProgramSrc -repository-id=translationsmodule +module-id=translationsmodule dependencies=filesmodule -github-repository=TheProgramSrc/SimpleCore-TranslationsModule