Skip to content

Commit

Permalink
Merge pull request #12 from usefulness/updates
Browse files Browse the repository at this point in the history
BehaviorOnFailure -> BehaviorOnMismatch
  • Loading branch information
mateuszkwiecinski authored Mar 30, 2024
2 parents 3c1ffdc + c7dfdf0 commit 9411f67
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ From now on, the `sympathyForMrMaven` will run on every `check` task invocation.

```groovy
tasks.named("sympathyForMrMaven") {
behaviorOnFailure = BehaviorOnFailure.Fail
behaviorOnMismatch = BehaviorOnMismatch.Fail
}
```
</details>
Expand All @@ -40,9 +40,9 @@ tasks.named("sympathyForMrMaven") {

```kotlin
tasks.named<io.github.usefulness.mavensympathy.SympathyForMrMavenTask>("sympathyForMrMaven") {
behaviorOnFailure = BehaviorOnFailure.Fail
behaviorOnMismatch = BehaviorOnMismatch.Fail
}
```
</details>

`behaviorOnFailure` - one of `Fail` (prints error logs + fails the build) or `Warn` (only prints error logs)
`behaviorOnMismatch` - one of `Fail` (prints error logs + fails the build) or `Warn` (only prints error logs)
14 changes: 7 additions & 7 deletions maven-sympathy/api/maven-sympathy.api
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
public final class io/github/usefulness/mavensympathy/BehaviorOnFailure : java/lang/Enum {
public static final field Fail Lio/github/usefulness/mavensympathy/BehaviorOnFailure;
public static final field Warn Lio/github/usefulness/mavensympathy/BehaviorOnFailure;
public final class io/github/usefulness/mavensympathy/BehaviorOnMismatch : java/lang/Enum {
public static final field Fail Lio/github/usefulness/mavensympathy/BehaviorOnMismatch;
public static final field Warn Lio/github/usefulness/mavensympathy/BehaviorOnMismatch;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/github/usefulness/mavensympathy/BehaviorOnFailure;
public static fun values ()[Lio/github/usefulness/mavensympathy/BehaviorOnFailure;
public static fun valueOf (Ljava/lang/String;)Lio/github/usefulness/mavensympathy/BehaviorOnMismatch;
public static fun values ()[Lio/github/usefulness/mavensympathy/BehaviorOnMismatch;
}

public final class io/github/usefulness/mavensympathy/MavenSympathyPlugin : org/gradle/api/Plugin {
Expand All @@ -14,8 +14,8 @@ public final class io/github/usefulness/mavensympathy/MavenSympathyPlugin : org/

public class io/github/usefulness/mavensympathy/SympathyForMrMavenTask : org/gradle/api/DefaultTask {
public fun <init> (Lorg/gradle/api/model/ObjectFactory;)V
public final fun behaviorOnFailure (Ljava/lang/String;)V
public final fun getBehaviorOnFailure ()Lorg/gradle/api/provider/Property;
public final fun behaviorOnMismatch (Ljava/lang/String;)V
public final fun getBehaviorOnMismatch ()Lorg/gradle/api/provider/Property;
public final fun getConfigurationWithDependencies ()Lorg/gradle/api/provider/MapProperty;
public final fun getOutputFile ()Lorg/gradle/api/file/RegularFileProperty;
public final fun run ()V
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.usefulness.mavensympathy

public enum class BehaviorOnFailure {
public enum class BehaviorOnMismatch {
Warn,
Fail,
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public open class SympathyForMrMavenTask @Inject constructor(objectFactory: Obje
public val outputFile: RegularFileProperty = objectFactory.fileProperty()

@Input
public val behaviorOnFailure: Property<BehaviorOnFailure> = objectFactory.property(BehaviorOnFailure::class.java)
.value(BehaviorOnFailure.Fail)
public val behaviorOnMismatch: Property<BehaviorOnMismatch> = objectFactory.property(BehaviorOnMismatch::class.java)
.value(BehaviorOnMismatch.Fail)

public fun behaviorOnFailure(value: String) {
behaviorOnFailure.set(BehaviorOnFailure.entries.first { it.name.equals(value, ignoreCase = true) })
public fun behaviorOnMismatch(value: String) {
behaviorOnMismatch.set(BehaviorOnMismatch.entries.first { it.name.equals(value, ignoreCase = true) })
}

@TaskAction
Expand All @@ -56,9 +56,9 @@ public open class SympathyForMrMavenTask @Inject constructor(objectFactory: Obje
report.writeText(errorMessages.joinToString(separator = "\n"))
val failureMessage = "Declared dependencies were upgraded transitively. See task output above. Please update their versions."

when (behaviorOnFailure.get()) {
BehaviorOnFailure.Warn -> logger.error(failureMessage)
BehaviorOnFailure.Fail, null -> error(failureMessage)
when (behaviorOnMismatch.get()) {
BehaviorOnMismatch.Warn -> logger.error(failureMessage)
BehaviorOnMismatch.Fail, null -> error(failureMessage)
}
} else {
report.writeText("OK")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,16 @@ class IntegrationTest {
// language=groovy
writeText(
"""
import io.github.usefulness.mavensympathy.BehaviorOnFailure
import io.github.usefulness.mavensympathy.BehaviorOnMismatch
plugins {
id("java-library")
id("io.github.usefulness.maven-sympathy")
}
tasks.named("sympathyForMrMaven") {
behaviorOnFailure "fail"
behaviorOnFailure = BehaviorOnFailure.Warn
behaviorOnMismatch "fail"
behaviorOnMismatch = BehaviorOnMismatch.Warn
}
dependencies {
Expand Down

0 comments on commit 9411f67

Please sign in to comment.