Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ApplicationSpec extends BasePluginSpecification {
}

rootProject.name = 'myapp'
""".stripIndent()
""".stripIndent() + getSettingsBuildScript(false)

when:
BuildResult result = run('runShadow')
Expand Down Expand Up @@ -152,7 +152,7 @@ class ApplicationSpec extends BasePluginSpecification {
jar?.close()
}

@Issue('SHADOW-89')
@Issue('https://github.com/GradleUp/shadow/issues/89')
def 'shadow application distributions should use shadow jar'() {
given:
repo.module('shadow', 'a', '1.0')
Expand Down Expand Up @@ -204,7 +204,7 @@ class ApplicationSpec extends BasePluginSpecification {
zipFile?.close()
}

@Issue('SHADOW-90')
@Issue('https://github.com/GradleUp/shadow/issues/90')
def 'installShadow does not execute dependent shadow task'() {
given:
repo.module('shadow', 'a', '1.0')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.util.AppendableJar
import com.github.jengelman.gradle.plugins.shadow.util.AppendableMavenFileRepository
import org.codehaus.plexus.util.IOUtil
Expand All @@ -25,35 +26,51 @@ abstract class BasePluginSpecification extends Specification {
repo = repo()
repo.module('junit', 'junit', '3.8.2').use(testJar).publish()

buildFile << defaultBuildScript

settingsFile << '''
rootProject.name = 'shadow'
'''
buildFile << getDefaultBuildScript('java', true, true)
buildFile << System.lineSeparator()
settingsFile << settingsBuildScript
settingsFile << System.lineSeparator()
}

def cleanup() {
println buildFile.text
}

String getDefaultBuildScript(String javaPlugin = 'java') {
String getDefaultBuildScript(
String javaPlugin = 'java',
boolean withGroup = false,
boolean withVersion = false
) {
def groupInfo = withGroup ? "group = 'shadow'" : ""
def versionInfo = withVersion ? "version = '1.0'" : ""

return """
plugins {
id '${javaPlugin}'
id 'com.gradleup.shadow'
}

version = "1.0"
group = 'shadow'
$groupInfo
$versionInfo
""".stripIndent().trim()
}

sourceSets {
integTest
}
String getSettingsBuildScript(boolean withRootProject = true) {
def rootProjectInfo = withRootProject ? "rootProject.name = 'shadow'" : ""
return """
dependencyResolutionManagement {
repositories {
maven { url = "${repo.uri}" }
mavenCentral()
}
}

repositories { maven { url = "${repo.uri}" } }
""".stripIndent()
$rootProjectInfo
""".stripIndent().trim()
}

static def shadowJar = "tasks.named('shadowJar', ${ShadowJar.class.name})".trim()

GradleRunner getRunner() {
GradleRunner.create()
.withProjectDir(dir.toFile())
Expand All @@ -63,7 +80,7 @@ abstract class BasePluginSpecification extends Specification {
}

GradleRunner runner(Collection<String> tasks) {
runner.withArguments(["-Dorg.gradle.warning.mode=all", "--configuration-cache", "--stacktrace"] + tasks.toList())
runner.withArguments(["--warning-mode=fail", "--configuration-cache", "--stacktrace"] + tasks.toList())
}

BuildResult run(String... tasks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ConfigurationCacheSpec extends BasePluginSpecification {
def "configuration caching supports includes"() {
given:
buildFile << """
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
$shadowJar {
exclude 'a2.properties'
}
""".stripIndent()
Expand Down Expand Up @@ -91,7 +91,7 @@ class ConfigurationCacheSpec extends BasePluginSpecification {
""".stripIndent()
file('client/build.gradle') << """
apply plugin: 'java'
repositories { maven { url = "${repo.uri}" } }

dependencies { implementation 'junit:junit:3.8.2' }
""".stripIndent()

Expand All @@ -101,26 +101,24 @@ class ConfigurationCacheSpec extends BasePluginSpecification {
public class Server {}
""".stripIndent()
file('server/build.gradle') << """
apply plugin: 'java'
apply plugin: 'com.gradleup.shadow'
$defaultBuildScript

tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
$shadowJar {
minimize {
exclude(dependency('junit:junit:.*'))
}
}

repositories { maven { url = "${repo.uri}" } }
dependencies { implementation project(':client') }
""".stripIndent()

and:
def output = getFile('server/build/libs/server-all.jar')

when:
run('shadowJar', '-s')
run('shadowJar')
output.delete()
def result = run('shadowJar', '-s')
def result = run('shadowJar')

then:
output.exists()
Expand All @@ -146,23 +144,21 @@ class ConfigurationCacheSpec extends BasePluginSpecification {
public class Lib {}
""".stripIndent()
file('lib/build.gradle') << """
apply plugin: 'java'
apply plugin: 'com.gradleup.shadow'
$defaultBuildScript

repositories { maven { url = "${repo.uri}" } }
dependencies {
implementation "junit:junit:3.8.2"
}

tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
$shadowJar {
configurations = [project.configurations.compileClasspath]
}

""".stripIndent()

when:
run('shadowJar', '-s')
def result = run('shadowJar', '-s')
run('shadowJar')
def result = run('shadowJar')

then:
result.output.contains(":lib:shadowJar UP-TO-DATE")
Expand Down

This file was deleted.

Loading
Loading