-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To prevent the plugin from shipping its own slf4j-api jar, which is improperly relocated and hence fails to bind to the gradle provided sfl4j implementation, this commit excludes the slf4j-api from grgit. The commit additionally contains an integration test that tests the shadowed plugin jar to ensure slf4j can properly bind.
- Loading branch information
Showing
2 changed files
with
66 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
46 changes: 46 additions & 0 deletions
46
src/integrationTest/groovy/com/gorylenko/SLF4JBindingPostShadowTest.groovy
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,46 @@ | ||
package com.gorylenko | ||
|
||
import com.gorylenko.properties.GitRepositoryBuilder | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.TemporaryFolder | ||
|
||
import static org.junit.Assert.* | ||
|
||
class SLF4JBindingPostShadowTest { | ||
@Rule | ||
public final TemporaryFolder temporaryFolder = new TemporaryFolder() | ||
|
||
@Test | ||
void testSFL4JBindingPostShadow() { | ||
def projectDir = temporaryFolder.newFolder() | ||
|
||
def integrationPluginPath = System.properties.get("integration.plugin.path") // Fetch integration jar from shadowJar output | ||
assertNotNull("integration.plugin.path was null", integrationPluginPath) | ||
|
||
GitRepositoryBuilder.setupProjectDir(projectDir, { gitRepoBuilder -> | ||
// commit 1 new file "hello.txt" | ||
gitRepoBuilder.commitFile("hello.txt", "Hello", "Added hello.txt") | ||
}) | ||
|
||
new File(projectDir, "settings.gradle") << "" | ||
new File(projectDir, "build.gradle") << """ | ||
plugins { | ||
id('com.gorylenko.gradle-git-properties') | ||
} | ||
""".stripIndent() | ||
|
||
def runner = GradleRunner.create() | ||
.withPluginClasspath(Arrays.asList(new File(integrationPluginPath as String))) // Use integration plugin jar | ||
.withArguments("generateGitProperties") | ||
.withProjectDir(projectDir) | ||
|
||
def result = runner.build() | ||
|
||
assertEquals(TaskOutcome.SUCCESS, result.task(":generateGitProperties").outcome) | ||
assertFalse("Project improperly shadowed slf4j-api!", result.output.contains("org.slf4j.impl.StaticLoggerBinder")) | ||
} | ||
|
||
} |