diff --git a/.github/workflows/.java-version b/.github/workflows/.java-version new file mode 100644 index 0000000..98d9bcb --- /dev/null +++ b/.github/workflows/.java-version @@ -0,0 +1 @@ +17 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bf90fb..d74e455 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,13 +4,8 @@ on: [push, pull_request, merge_group] jobs: build: - name: JDK ${{ matrix.java_version }} runs-on: ubuntu-latest - strategy: - matrix: - java_version: [11] - steps: - name: Checkout uses: actions/checkout@v4 @@ -19,13 +14,24 @@ jobs: uses: gradle/actions/wrapper-validation@v4 - name: Setup gradle - uses: gradle/gradle-build-action@v3 + uses: gradle/actions/setup-gradle@v4 - name: Install JDK ${{ matrix.java_version }} uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: ${{ matrix.java_version }} + java-version-file: .github/workflows/.java-version + + - name: Install Graphviz + run: sudo apt-get update && sudo apt-get install -y graphviz - name: Build with Gradle run: ./gradlew build --stacktrace + + - name: Upload reports + uses: actions/upload-artifact@v4 + if: always() + with: + name: check-reports + path: "./build/reports" + if-no-files-found: warn diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 5012b99..56db120 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,10 +19,10 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version-file: .github/workflows/.java-version - name: Setup gradle - uses: gradle/gradle-build-action@v3 + uses: gradle/actions/setup-gradle@v4 - name: Publish release run: ./gradlew publishAllPublicationsToMavenCentralRepository diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 90292d4..880e2b4 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -19,10 +19,10 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version-file: .github/workflows/.java-version - name: Setup gradle - uses: gradle/gradle-build-action@v3 + uses: gradle/actions/setup-gradle@v4 - name: Retrieve version run: | diff --git a/.gitignore b/.gitignore index f376ce2..6a8d1c5 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .gradle/ +.kotlin/ build/ out/ diff --git a/build.gradle b/build.gradle index d5d74b6..d3a77ae 100755 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ validatePlugins { codeQualityTools { ktlint { toolVersion = "0.47.1" + enabled = false } detekt { enabled = false @@ -67,7 +68,7 @@ dependencies { api "guru.nidi:graphviz-java:0.18.1" testImplementation 'junit:junit:4.13.2' - testImplementation "com.android.tools.build:gradle:7.3.1" + testImplementation "com.android.tools.build:gradle:8.10.0" testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" // https://github.com/gradle/gradle/issues/16774#issuecomment-893493869 @@ -79,10 +80,10 @@ dependencies { testRuntimeOnly(files(toolingApiBuildersJar)) } -sourceCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_17 wrapper { - gradleVersion = '7.6.4' + gradleVersion = '8.14' distributionType = Wrapper.DistributionType.ALL } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index afba109..1b33c55 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 5c00f61..6514f91 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..23d15a9 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,10 +85,8 @@ done # 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"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -133,10 +133,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +147,7 @@ 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 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +155,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,16 +200,20 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# 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"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 6689b85..5eed7ee 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,22 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyContainer.kt b/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyContainer.kt index 747194b..99d366a 100644 --- a/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyContainer.kt +++ b/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyContainer.kt @@ -10,11 +10,11 @@ sealed interface DependencyContainer { internal operator fun invoke(dependency: GradleResolvedDependency) = ResolvedDependency(dependency) } - data class Project internal constructor( + data class Project( internal val project: GradleProject, ) : DependencyContainer, GradleProject by project - data class ResolvedDependency internal constructor( + data class ResolvedDependency( internal val resolvedDependency: GradleResolvedDependency, ) : DependencyContainer, GradleResolvedDependency by resolvedDependency } diff --git a/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPlugin.kt b/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPlugin.kt index ee61b7b..6d576c2 100644 --- a/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPlugin.kt +++ b/src/main/kotlin/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPlugin.kt @@ -13,7 +13,7 @@ open class DependencyGraphGeneratorPlugin : Plugin { it.generator = generator it.group = "reporting" it.description = "Generates a dependency graph${generator.name.nonEmptyPrepend(" for ")}" - it.outputDirectory = File(project.buildDir, "reports/dependency-graph/") + it.outputDirectory = File(project.buildDirectory, "reports/dependency-graph/") } } @@ -22,7 +22,7 @@ open class DependencyGraphGeneratorPlugin : Plugin { it.projectGenerator = projectGenerator it.group = "reporting" it.description = "Generates a project dependency graph${projectGenerator.name.nonEmptyPrepend(" for ")}" - it.outputDirectory = File(project.buildDir, "reports/project-dependency-graph/") + it.outputDirectory = File(project.buildDirectory, "reports/project-dependency-graph/") } } } diff --git a/src/main/kotlin/com/vanniktech/dependency/graph/generator/ProjectDependencyGraphGenerator.kt b/src/main/kotlin/com/vanniktech/dependency/graph/generator/ProjectDependencyGraphGenerator.kt index 88a9284..f4b571e 100644 --- a/src/main/kotlin/com/vanniktech/dependency/graph/generator/ProjectDependencyGraphGenerator.kt +++ b/src/main/kotlin/com/vanniktech/dependency/graph/generator/ProjectDependencyGraphGenerator.kt @@ -32,7 +32,7 @@ internal class ProjectDependencyGraphGenerator( .flatMap { configuration -> configuration.dependencies .withType(ProjectDependency::class.java) - .map { ProjectDependencyContainer(project, it.dependencyProject, configuration) } + .map { ProjectDependencyContainer(project, project.project(it.path), configuration) } } .forEach { dependencies.add(it) diff --git a/src/main/kotlin/com/vanniktech/dependency/graph/generator/extensions.kt b/src/main/kotlin/com/vanniktech/dependency/graph/generator/extensions.kt index 4bc9437..c330aee 100644 --- a/src/main/kotlin/com/vanniktech/dependency/graph/generator/extensions.kt +++ b/src/main/kotlin/com/vanniktech/dependency/graph/generator/extensions.kt @@ -4,6 +4,7 @@ import com.vanniktech.dependency.graph.generator.ProjectTarget.MULTIPLATFORM import org.gradle.api.Project import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ProjectDependency +import java.io.File internal fun String.nonEmptyPrepend(prepend: String) = if (isNotEmpty()) prepend + this else this @@ -34,3 +35,6 @@ internal fun Project.target(): ProjectTarget { } internal fun Configuration.isImplementation() = name.lowercase().endsWith("implementation") + +internal val Project.buildDirectory: File + get() = layout.buildDirectory.asFile.get() diff --git a/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPluginTest.kt b/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPluginTest.kt index f6c0c72..f838e0c 100644 --- a/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPluginTest.kt +++ b/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorPluginTest.kt @@ -39,7 +39,7 @@ class DependencyGraphGeneratorPluginTest { assertEquals(true, task.generator === Generator.ALL) assertEquals("reporting", task.group) assertEquals("Generates a dependency graph", task.description) - assertEquals(File(singleProject.buildDir, "reports/dependency-graph/").toString(), task.outputDirectory.toString()) + assertEquals(File(singleProject.buildDirectory, "reports/dependency-graph/").toString(), task.outputDirectory.toString()) } @Test fun taskPropertiesProject() { @@ -51,11 +51,11 @@ class DependencyGraphGeneratorPluginTest { assertEquals(true, task.projectGenerator === ProjectGenerator.ALL) assertEquals("reporting", task.group) assertEquals("Generates a project dependency graph", task.description) - assertEquals(File(singleProject.buildDir, "reports/project-dependency-graph/").toString(), task.outputDirectory.toString()) + assertEquals(File(singleProject.buildDirectory, "reports/project-dependency-graph/").toString(), task.outputDirectory.toString()) } - @Test fun integrationTestGradle742() { - integrationTest("7.4.2") + @Test fun integrationTestGradle814() { + integrationTest("8.14") } @Suppress("Detekt.LongMethod") private fun integrationTest(gradleVersion: String) { @@ -280,7 +280,7 @@ class DependencyGraphGeneratorPluginTest { val result = GradleRunner.create().withDebug(true) .withPluginClasspath() - .withGradleVersion("7.4.2") + .withGradleVersion("8.14") .withProjectDir(testProjectDir.root) .withArguments("generateDependencyGraph", "generateProjectDependencyGraph", "app:generateProjectDependencyGraph", "-Dorg.gradle.jvmargs=-Xmx2048m", "--stacktrace") .build() diff --git a/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorTest.kt b/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorTest.kt index 3582097..1f24cd1 100644 --- a/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorTest.kt +++ b/src/test/java/com/vanniktech/dependency/graph/generator/DependencyGraphGeneratorTest.kt @@ -68,9 +68,10 @@ class DependencyGraphGeneratorTest { androidProjectExtension = androidProject.extensions.getByType(AppExtension::class.java) androidProjectExtension.compileSdkVersion(27) + androidProjectExtension.namespace = "com.foo.bar" val manifestFile = File(androidProject.projectDir, "src/main/AndroidManifest.xml") manifestFile.parentFile.mkdirs() - manifestFile.writeText("""""") + manifestFile.writeText("""""") } @Test fun singleProjectAllNoTestDependencies() {