diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml index 8bb468c3..4bace5e1 100644 --- a/.github/workflows/build-and-publish.yaml +++ b/.github/workflows/build-and-publish.yaml @@ -24,16 +24,9 @@ jobs: java-version: 17 cache: 'gradle' - - name: Test and Compile with Gradle + - name: Test and Compile with Gradle, and publish artifacts run: | ./gradlew \ - -PartifactoryUsername="${{ secrets.ARTIFACTORY_USERNAME }}" \ - -PartifactoryPassword="${{ secrets.ARTIFACTORY_API_KEY }}" \ - clean check --parallel - - - name: Publish JARs to Artifactory - run: | - ./gradlew \ - -PartifactoryUsername="${{ secrets.ARTIFACTORY_USERNAME }}" \ - -PartifactoryPassword="${{ secrets.ARTIFACTORY_API_KEY }}" \ - publish --parallel -x check \ No newline at end of file + -PgithubUsername="${{ secrets.REPOSITORY_USERNAME }}" \ + -PgithubPassword="${{ secrets.REPOSITORY_TOKEN }}" \ + clean check assemble publish --parallel \ No newline at end of file diff --git a/.github/workflows/dependency-reporter.yml b/.github/workflows/dependency-reporter.yml index 59f21652..0b30eddf 100644 --- a/.github/workflows/dependency-reporter.yml +++ b/.github/workflows/dependency-reporter.yml @@ -19,12 +19,12 @@ jobs: java-version: 17 cache: 'gradle' - name: Setup Gradle to generate and submit dependency graphs - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 with: dependency-graph: generate-and-submit - name: Run a build and generate the dependency graph which will be submitted post-job run: | ./gradlew \ - -PartifactoryUsername="${{ secrets.ARTIFACTORY_USERNAME }}" \ - -PartifactoryPassword="${{ secrets.ARTIFACTORY_API_KEY }}" \ + -PgithubUsername="${{ secrets.REPOSITORY_USERNAME }}" \ + -PgithubPassword="${{ secrets.REPOSITORY_TOKEN }}" \ assemble -x test diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index 4b0386c7..de4833ae 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -22,8 +22,8 @@ jobs: - name: Assemble and publish run: | ./gradlew \ - -PartifactoryUsername=${{ secrets.ARTIFACTORY_USERNAME }} \ - -PartifactoryPassword=${{ secrets.ARTIFACTORY_API_KEY }} \ + -PgithubUsername="${{ secrets.REPOSITORY_USERNAME }}" \ + -PgithubPassword="${{ secrets.REPOSITORY_TOKEN }}" \ -Prelease="true" \ -Penvironment=production \ -Preckon.stage="final" \ diff --git a/build.gradle b/build.gradle deleted file mode 100644 index c6f568cb..00000000 --- a/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -plugins { - id "java-conventions" - id "unit-test-conventions" - id "library-conventions" - id "publication-conventions" - id("org.ajoberstar.reckon") version "0.13.1" -} - -reckon { - scopeFromProp() - snapshotFromProp() -} - -repositories { - mavenCentral() -} - -dependencies { - implementation("javax.validation:validation-api:1.1.0.Final") - implementation("com.google.code.gson:gson:2.9.1") - implementation("org.apache.commons:commons-lang3:3.4") - implementation('com.google.guava:guava:33.0.0-jre') - implementation("org.slf4j:slf4j-api:1.7.27") - implementation("org.slf4j:slf4j-simple:1.7.27") - implementation("org.apache.httpcomponents:httpclient:4.5.14") - implementation("org.apache.httpcomponents:httpmime:4.5.14") - testImplementation("org.apache.httpcomponents:httpclient:4.5.14:tests") - implementation("org.junit.jupiter:junit-jupiter:5.10.2") - testImplementation("org.springframework:spring-beans:6.1.5") - testImplementation("org.springframework:spring-context:6.1.5") - testImplementation("org.springframework:spring-test:6.1.5") - testImplementation("org.mockito:mockito-core:5.3.1") - testImplementation("org.mockito:mockito-junit-jupiter:5.3.1") - testImplementation("org.hamcrest:hamcrest:2.2") -} - -group = "edu.ksu.canvas" -description = "Canvas API Library" - diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..f5033866 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,72 @@ +plugins { + id("java-library") + id("maven-publish") + alias(libs.plugins.reckon) + alias(libs.plugins.ben.manes.versions) + alias(libs.plugins.sweng.publication) + alias(libs.plugins.version.catalog.update) +} + +group = "edu.ksu.canvas" +description = "Canvas API Library" + +reckon { + scopeFromProp() + snapshotFromProp() +} + +repositories { + mavenCentral() +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + vendor = JvmVendorSpec.ADOPTIUM + + withJavadocJar() + withSourcesJar() + } +} + +tasks.named("test") { + useJUnitPlatform() + testLogging { + events("started", "passed", "failed", "skipped") + testLogging.showStandardStreams = true + showStackTraces = true + } +} + +publishing { + publications { + create("maven") { + groupId = "${project.group}" + artifactId = project.name + version = "${project.version}" + + from(components["java"]) + } + } +} + +dependencies { + implementation(libs.validation.api) + implementation(libs.gson) + implementation(libs.commons.lang3) + implementation(libs.guava) + implementation(libs.slf4j.api) + implementation(libs.slf4j.simple) + implementation(libs.httpclient) + implementation(libs.httpmime) + testImplementation(libs.junit.jupiter) + testImplementation(libs.httpclient) { artifact { classifier = "tests" } } + testImplementation(libs.spring.beans) + testImplementation(libs.spring.context) + testImplementation(libs.spring.test) + testImplementation(libs.mockito.core) + testImplementation(libs.mockito.junit.jupiter) + testImplementation(libs.hamcrest) +} + + diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index c649c23a..00000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - id "groovy-gradle-plugin" -} - -repositories { - gradlePluginPortal() -} - -dependencies { - implementation("com.palantir.gradle.docker:gradle-docker:0.33.0") - implementation("org.springframework.boot:spring-boot-gradle-plugin:3.2.0") -} \ No newline at end of file diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle deleted file mode 100644 index 3f87d39f..00000000 --- a/buildSrc/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "buildSrc" \ No newline at end of file diff --git a/buildSrc/src/main/groovy/common-methods.gradle b/buildSrc/src/main/groovy/common-methods.gradle deleted file mode 100644 index 7fd881b8..00000000 --- a/buildSrc/src/main/groovy/common-methods.gradle +++ /dev/null @@ -1,40 +0,0 @@ -// Exports a common set of methods to one place to reduce code duplication -// References: https://stackoverflow.com/a/18718802/1079354 -// and https://stackoverflow.com/a/23290820/1079354 - -def retrieveUsername() { - return project.hasProperty('artifactoryUsername') ? project.property('artifactoryUsername') : '' -} - -def retrievePassword() { - return project.hasProperty('artifactoryPassword') ? project.property('artifactoryPassword') : '' -} - -def isReleaseBuild() { - return project.hasProperty("release") && Boolean.valueOf((String) project.property("release")) -} - -def getCheckedOutGitCommitHash() { - 'git rev-parse --verify --short HEAD'.execute().text.trim() -} - -// Only deploy production artifacts to libs-release-local. -// No property - assume running in development, and deploy to snapshots. -def retrieveRepository() { - def releaseRepoUrl = "https://artifactory.colorado.edu/artifactory/software-engineering-libs-release-local" - def snapshotRepoUrl = "https://artifactory.colorado.edu/artifactory/software-engineering-libs-snapshot-local" - - if (isReleaseBuild()) { - return releaseRepoUrl - } else { - return snapshotRepoUrl - } -} - -ext { - retrieveUsername = this.&retrieveUsername - retrievePassword = this.&retrievePassword - isReleaseBuild = this.&isReleaseBuild - retrieveRepository = this.&retrieveRepository - getCheckedOutGitCommitHash = this.&getCheckedOutGitCommitHash -} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/java-conventions.gradle b/buildSrc/src/main/groovy/java-conventions.gradle deleted file mode 100644 index 6062d27b..00000000 --- a/buildSrc/src/main/groovy/java-conventions.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id "java-library" -} - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) - vendor = JvmVendorSpec.ADOPTIUM - } -} - -tasks.withType(JavaExec).configureEach { - javaLauncher.set(javaToolchains.launcherFor(java.toolchain)) -} diff --git a/buildSrc/src/main/groovy/library-conventions.gradle b/buildSrc/src/main/groovy/library-conventions.gradle deleted file mode 100644 index 08933157..00000000 --- a/buildSrc/src/main/groovy/library-conventions.gradle +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - id "java-library" - id "maven-publish" - id "org.springframework.boot" -} - -tasks.named("bootJar") { - enabled = false -} - -tasks.named("jar") { - enabled = true -} diff --git a/buildSrc/src/main/groovy/publication-conventions.gradle b/buildSrc/src/main/groovy/publication-conventions.gradle deleted file mode 100644 index f2f0833a..00000000 --- a/buildSrc/src/main/groovy/publication-conventions.gradle +++ /dev/null @@ -1,33 +0,0 @@ -plugins { - id "maven-publish" - id "common-methods" -} - -afterEvaluate { - publishing { - repositories { - maven { - url(retrieveRepository()) - credentials { - username = retrieveUsername() - password = retrievePassword() - } - authentication { - basic(BasicAuthentication) - } - } - } - - publications { - maven(MavenPublication) { - groupId = project.group - artifactId = jar.archiveBaseName.get() - version = project.version - - from components.java - } - } - } -} - - diff --git a/buildSrc/src/main/groovy/unit-test-conventions.gradle b/buildSrc/src/main/groovy/unit-test-conventions.gradle deleted file mode 100644 index 2e4c5a48..00000000 --- a/buildSrc/src/main/groovy/unit-test-conventions.gradle +++ /dev/null @@ -1,22 +0,0 @@ -plugins { - id "java-library" -} - -test { - useJUnitPlatform() - testLogging { - events "failed", "skipped" - showStackTraces true - exceptionFormat "full" - showStandardStreams false - - debug { - showStandardStreams true - } - } - // For Mockito wanting to instrument classes that it doesn't have direct access to - // See https://stackoverflow.com/a/70441435 for details - jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED' -} - - diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..c14a1bb3 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,38 @@ +[versions] +commons-lang3 = "3.16.0" +gson = "2.11.0" +guava = "33.2.1-jre" +hamcrest = "3.0" +junit-jupiter = "5.11.0" +org-apache-httpcomponents = "4.5.14" +org-mockito = "5.12.0" +org-slf4j = "2.0.16" +org-springframework = "6.1.12" +plugin-ben-manes-versions = "0.51.0" +plugin-reckon = "0.13.1" +plugin-sweng-publication = "2.+" +plugin-version-catalog-update = "0.8.4" +validation-api = "2.0.1.Final" + +[libraries] +commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commons-lang3" } +gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +guava = { module = "com.google.guava:guava", version.ref = "guava" } +hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" } +httpclient = { module = "org.apache.httpcomponents:httpclient", version.ref = "org-apache-httpcomponents" } +httpmime = { module = "org.apache.httpcomponents:httpmime", version.ref = "org-apache-httpcomponents" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" } +mockito-core = { module = "org.mockito:mockito-core", version.ref = "org-mockito" } +mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "org-mockito" } +slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "org-slf4j" } +slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "org-slf4j" } +spring-beans = { module = "org.springframework:spring-beans", version.ref = "org-springframework" } +spring-context = { module = "org.springframework:spring-context", version.ref = "org-springframework" } +spring-test = { module = "org.springframework:spring-test", version.ref = "org-springframework" } +validation-api = { module = "javax.validation:validation-api", version.ref = "validation-api" } + +[plugins] +ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "plugin-ben-manes-versions" } +reckon = { id = "org.ajoberstar.reckon", version.ref = "plugin-reckon" } +sweng-publication = { id = "edu.colorado.oit.se.gradle.github-repository-convention", version.ref = "plugin-sweng-publication" } +version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "plugin-version-catalog-update" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f..943f0cbf 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 070cb702..707e499a 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.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c7873..65dcd68d 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 @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32..6689b85b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +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% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 9bc795a3..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "canvas-api" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..ea5a3e64 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,12 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = "github" + url = uri("https://maven.pkg.github.com/UCBoulder/sweng-gradle-repository-config-plugin") + credentials(PasswordCredentials::class) + } + } +} + +rootProject.name = "canvas-api"