Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jraska/modules-graph-assert
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.7.0
Choose a base ref
...
head repository: jraska/modules-graph-assert
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 17 commits
  • 12 files changed
  • 5 contributors

Commits on Aug 28, 2024

  1. Copy the full SHA
    0c2c589 View commit details
  2. Copy the full SHA
    74cf790 View commit details

Commits on Sep 2, 2024

  1. Bump com.gradle.plugin-publish from 1.2.1 to 1.2.2 (#281)

    Bumps com.gradle.plugin-publish from 1.2.1 to 1.2.2.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle.plugin-publish
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Sep 2, 2024
    Copy the full SHA
    1972265 View commit details

Commits on Sep 17, 2024

  1. Bump com.gradle.plugin-publish from 1.2.2 to 1.3.0 (#282)

    Bumps com.gradle.plugin-publish from 1.2.2 to 1.3.0.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle.plugin-publish
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Sep 17, 2024
    Copy the full SHA
    2e8f424 View commit details

Commits on Oct 14, 2024

  1. Bump kotlin_version from 2.0.20 to 2.0.21 (#284)

    Bumps `kotlin_version` from 2.0.20 to 2.0.21.
    
    Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 2.0.20 to 2.0.21
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/v2.0.21/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.0.20...v2.0.21)
    
    Updates `org.jetbrains.kotlin:kotlin-stdlib-jdk8` from 2.0.20 to 2.0.21
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/v2.0.21/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.0.20...v2.0.21)
    
    ---
    updated-dependencies:
    - dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-patch
    - dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 14, 2024
    Copy the full SHA
    7f5b653 View commit details

Commits on Oct 26, 2024

  1. Copy the full SHA
    03a3d40 View commit details

Commits on Dec 24, 2024

  1. Bump kotlin_version from 2.0.21 to 2.1.0 (#287)

    Bumps `kotlin_version` from 2.0.21 to 2.1.0.
    
    Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 2.0.21 to 2.1.0
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.0.21...v2.1.0)
    
    Updates `org.jetbrains.kotlin:kotlin-stdlib-jdk8` from 2.0.21 to 2.1.0
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.0.21...v2.1.0)
    
    ---
    updated-dependencies:
    - dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 24, 2024
    Copy the full SHA
    bad7704 View commit details

Commits on Jan 14, 2025

  1. add license information to gradle.properties (#289)

    Co-authored-by: mr-thierry <thierry.roy@aexp.com>
    mr-thierry and mr-thierry authored Jan 14, 2025
    Copy the full SHA
    0386e2c View commit details
  2. Copy the full SHA
    c1c80a0 View commit details

Commits on Jan 15, 2025

  1. Add license information to POM file (#292)

    Co-authored-by: Thierry Roy <thierry.roy@aexp.com>
    mr-thierry and Thierry Roy authored Jan 15, 2025
    Copy the full SHA
    6cdffbd View commit details
  2. Copy the full SHA
    271c9a5 View commit details

Commits on Jan 28, 2025

  1. Bump kotlin_version from 2.1.0 to 2.1.10 (#295)

    Bumps `kotlin_version` from 2.1.0 to 2.1.10.
    
    Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 2.1.0 to 2.1.10
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.1.0...v2.1.10)
    
    Updates `org.jetbrains.kotlin:kotlin-stdlib-jdk8` from 2.1.0 to 2.1.10
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.1.0...v2.1.10)
    
    ---
    updated-dependencies:
    - dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-patch
    - dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 28, 2025
    Copy the full SHA
    ce2ede4 View commit details

Commits on Jan 29, 2025

  1. use VerificationException instead of GradleException, fixes #290 (#294)

    Develocity can classify exceptions into verification
    and non-verification exceptions. Using
    VerificationException ensures correct classification
    for non-infrastructure related failures.
    nebulon42 authored Jan 29, 2025
    Copy the full SHA
    25fc158 View commit details

Commits on Mar 2, 2025

  1. Bump com.gradle.plugin-publish from 1.3.0 to 1.3.1 (#297)

    Bumps com.gradle.plugin-publish from 1.3.0 to 1.3.1.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle.plugin-publish
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 2, 2025
    Copy the full SHA
    53f0d4d View commit details
  2. Gradle 8.13 (#299)

    jraska authored Mar 2, 2025
    Copy the full SHA
    ad4514f View commit details
  3. Revert maven metadata attempts (#301)

    * Revert "Add license information to POM file (#292)"
    
    This reverts commit 6cdffbd
    
    * Revert "add license information to gradle.properties (#289)"
    
    This reverts commit 0386e2c.
    jraska authored Mar 2, 2025
    Copy the full SHA
    3bc5388 View commit details
  4. Copy the full SHA
    ee2a329 View commit details
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ A Gradle plugin that helps keep your module graph healthy and lean.
Apply the plugin to a module, which dependencies graph you want to assert.
```groovy
plugins {
id "com.jraska.module.graph.assertion" version "2.7.0"
id "com.jraska.module.graph.assertion" version "2.8.0"
}
```

@@ -51,6 +51,12 @@ moduleGraphAssert {
}
```

#### Kotlin Multiplatform (KMP)
```groovy
configurations += setOf("commonMainImplementation", "commonMainApi") // different sourceSets defaults
```
- Please see [this issue](https://github.com/jraska/modules-graph-assert/issues/249#issuecomment-2437075587) for details and comment if you face issues.

### Module name alias
- You don't have to rely on module names and set a property `ext.moduleNameAssertAlias = "ThisWillBeAssertedOn"`
- This can be set on any module and the `allowed`/`restricted` rules would use the alias instead of module name for asserting.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '2.0.20'
ext.kotlin_version = '2.1.10'
repositories {
mavenCentral()
gradlePluginPortal()
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
4 changes: 2 additions & 2 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.gradle.plugin-publish" version "1.2.1"
id "com.gradle.plugin-publish" version "1.3.1"
id "java-gradle-plugin"
}

@@ -40,7 +40,7 @@ gradlePlugin {
plugins {
modulesGraphAssert {
id = 'com.jraska.module.graph.assertion'
version = '2.7.0'
version = '2.8.0'
displayName = 'Modules Graph Assert'
description = 'Gradle plugin to keep your modules graph healthy and lean.'
implementationClass = 'com.jraska.module.graph.assertion.ModuleGraphAssertionsPlugin'
Original file line number Diff line number Diff line change
@@ -29,11 +29,13 @@ class ModuleGraphAssertionsPlugin : Plugin<Project> {
override fun apply(project: Project) {
val graphRules = project.extensions.create(GraphRulesExtension::class.java, Api.EXTENSION_ROOT, GraphRulesExtension::class.java)

project.gradle.projectsEvaluated {
project.afterEvaluate {
addModulesAssertions(project, graphRules)

if (graphRules.assertOnAnyBuild) {
project.runAssertionsDirectly(graphRules)
project.gradle.projectsEvaluated {
project.runAssertionsDirectly(graphRules)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jraska.module.graph.assertion

import com.jraska.module.graph.DependencyGraph
import org.gradle.api.GradleException
import org.gradle.api.tasks.VerificationException
import java.io.Serializable

class ModuleTreeHeightAssert(
@@ -20,15 +20,15 @@ class ModuleTreeHeightAssert(
val height = dependencyGraph.heightOf(moduleName)
if (height > maxHeight) {
val longestPath = dependencyGraph.longestPath(moduleName)
throw GradleException("Module $moduleName is allowed to have maximum height of $maxHeight, but has $height, problematic dependencies: ${longestPath.pathString()}")
throw VerificationException("Module $moduleName is allowed to have maximum height of $maxHeight, but has $height, problematic dependencies: ${longestPath.pathString()}")
}
}

private fun assertWholeGraphHeight(dependencyGraph: DependencyGraph) {
val height = dependencyGraph.height()
if (height > maxHeight) {
val longestPath = dependencyGraph.longestPath()
throw GradleException("Module Graph is allowed to have maximum height of $maxHeight, but has $height, problematic dependencies: ${longestPath.pathString()}")
throw VerificationException("Module Graph is allowed to have maximum height of $maxHeight, but has $height, problematic dependencies: ${longestPath.pathString()}")
}
}
}
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package com.jraska.module.graph.assertion

import com.jraska.module.graph.DependencyGraph
import com.jraska.module.graph.Parse
import org.gradle.api.GradleException
import org.gradle.api.tasks.VerificationException

class OnlyAllowedAssert(
private val allowedDependencies: Array<String>,
@@ -18,7 +18,7 @@ class OnlyAllowedAssert(

if (disallowedDependencies.isNotEmpty()) {
val allowedRules = allowedDependencies.joinToString(", ") { "'$it'" }
throw GradleException("$disallowedDependencies not allowed by any of [$allowedRules]")
throw VerificationException("$disallowedDependencies not allowed by any of [$allowedRules]")
}
}
}
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package com.jraska.module.graph.assertion
import com.jraska.module.graph.DependencyGraph
import com.jraska.module.graph.Parse
import com.jraska.module.graph.RegexpDependencyMatcher
import org.gradle.api.GradleException
import org.gradle.api.tasks.VerificationException

class RestrictedDependenciesAssert(
private val errorMatchers: Array<String>,
@@ -20,7 +20,7 @@ class RestrictedDependenciesAssert(
}.filter { it.second.isNotEmpty() }

if (failedDependencies.isNotEmpty()) {
throw GradleException(buildErrorMessage(failedDependencies))
throw VerificationException(buildErrorMessage(failedDependencies))
}
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jraska.module.graph.assertion

import com.jraska.module.graph.DependencyGraph
import org.gradle.api.GradleException
import org.gradle.api.tasks.VerificationException
import org.junit.Test

class ModuleTreeHeightAssertTest {
@@ -12,7 +12,7 @@ class ModuleTreeHeightAssertTest {
ModuleTreeHeightAssert("app", 3).assert(dependencyGraph)
}

@Test(expected = GradleException::class)
@Test(expected = VerificationException::class)
fun failsOnTooLargeHeight() {
val dependencyGraph = testGraph()

@@ -26,7 +26,7 @@ class ModuleTreeHeightAssertTest {
ModuleTreeHeightAssert(null, 3).assert(dependencyGraph)
}

@Test(expected = GradleException::class)
@Test(expected = VerificationException::class)
fun failsOnTooHighGraphHeight() {
val dependencyGraph = testGraph()

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.jraska.module.graph.assertion

import com.jraska.module.graph.DependencyGraph
import org.gradle.api.GradleException
import org.gradle.api.tasks.VerificationException
import org.junit.Test

class OnlyAllowedAssertTest {
@Test(expected = GradleException::class)
@Test(expected = VerificationException::class)
fun failsWithNoMatchingMatchers() {
val dependencyGraph = testGraph()

@@ -33,7 +33,7 @@ class OnlyAllowedAssertTest {
OnlyAllowedAssert(allowedDependencies).assert(dependencyGraph)
}

@Test(expected = GradleException::class)
@Test(expected = VerificationException::class)
fun failsWhenOneNotAllowed() {
val dependencies = testGraph().dependencyPairs().toMutableList().apply { add("api" to "lib2") }
val dependencyGraph = DependencyGraph.create(dependencies)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jraska.module.graph.assertion

import com.jraska.module.graph.DependencyGraph
import org.gradle.api.GradleException
import org.gradle.api.tasks.VerificationException
import org.junit.Test

class RestrictedDependenciesAssertTest {
@@ -12,14 +12,14 @@ class RestrictedDependenciesAssertTest {
RestrictedDependenciesAssert(emptyArray()).assert(dependencyGraph)
}

@Test(expected = GradleException::class)
@Test(expected = VerificationException::class)
fun failsWhenFeatureCannotDependOnLib() {
val dependencyGraph = testGraph()

RestrictedDependenciesAssert(arrayOf("feature -X> lib2")).assert(dependencyGraph)
}

@Test(expected = GradleException::class)
@Test(expected = VerificationException::class)
fun failsWhenLibCannotDependOnAndroid() {
val dependencyGraph = testGraph()

@@ -48,7 +48,7 @@ class RestrictedDependenciesAssertTest {
).assert(dependencyGraph)
}

@Test(expected = GradleException::class)
@Test(expected = VerificationException::class)
fun failsWithMatchersToAlias() {
val dependencyGraph = DependencyGraph.create(
"app" to "feature",