-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CLI to ignore dependencies when wrapped by Gradle
When using Gradle, Gradle should handle dependency resolution, not the CLI. If we detect that Gradle is wrapping the CLI, dependency resolution is ignored. This helps ensure that previous versions of the Gradle plugin do not allow dependency resolution to occur, which would not work well with Gradle and could break users when they upgrade to a newer version of the Gradle plugin.
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
smithy-cli/src/test/java/software/amazon/smithy/cli/EnvironmentVariableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package software.amazon.smithy.cli; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class EnvironmentVariableTest { | ||
@Test | ||
public void ignoreDependenciesWhenRunningInGradle() { | ||
Object originalValue = System.getProperty("org.gradle.appname"); | ||
|
||
try { | ||
System.setProperty("org.gradle.appname", "foo"); | ||
assertThat(EnvironmentVariable.SMITHY_DEPENDENCY_MODE.get(), equalTo("ignore")); | ||
} finally { | ||
if (originalValue == null) { | ||
System.clearProperty("org.gradle.appname"); | ||
} else { | ||
System.setProperty("org.gradle.appname", originalValue.toString()); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void useStandardDependencyModeWhenRunningInGradle() { | ||
Object originalValue = System.getProperty("org.gradle.appname"); | ||
|
||
try { | ||
System.clearProperty("org.gradle.appname"); | ||
assertThat(EnvironmentVariable.SMITHY_DEPENDENCY_MODE.get(), equalTo("standard")); | ||
} finally { | ||
if (originalValue != null) { | ||
System.setProperty("org.gradle.appname", originalValue.toString()); | ||
} | ||
} | ||
} | ||
} |