"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "subprojects/core/src/integTest/groovy/org/gradle/normalization/ConfigureRuntimeClasspathNormalizationIntegrationTest.groovy" between
gradle-6.8.2-src.zip and gradle-6.8.3-src.zip

About: Gradle is a build tool with a focus on build automation and support for multi-language development.

ConfigureRuntimeClasspathNormalizationIntegrationTest.groovy  (gradle-6.8.2-src):ConfigureRuntimeClasspathNormalizationIntegrationTest.groovy  (gradle-6.8.3-src)
skipping to change at line 23 skipping to change at line 23
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.gradle.normalization package org.gradle.normalization
import org.gradle.integtests.fixtures.AbstractIntegrationSpec import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import org.gradle.integtests.fixtures.ToBeFixedForConfigurationCache import org.gradle.integtests.fixtures.ToBeFixedForConfigurationCache
import org.gradle.integtests.fixtures.UnsupportedWithConfigurationCache import org.gradle.integtests.fixtures.UnsupportedWithConfigurationCache
import org.gradle.test.fixtures.file.TestFile import org.gradle.test.fixtures.file.TestFile
import org.gradle.util.TextUtil
import spock.lang.Issue
import spock.lang.Unroll import spock.lang.Unroll
import java.util.jar.Attributes
import java.util.jar.Manifest
@Unroll @Unroll
class ConfigureRuntimeClasspathNormalizationIntegrationTest extends AbstractInte grationSpec { class ConfigureRuntimeClasspathNormalizationIntegrationTest extends AbstractInte grationSpec {
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt
def "can ignore files on runtime classpath in #tree (using runtime API: #use ps://github.com/gradle/gradle/issues/13706")
RuntimeApi)"() { def "can ignore files on runtime classpath in #tree (using runtime API: #api
)"() {
def project = new ProjectWithRuntimeClasspathNormalization(api).withFile sIgnored() def project = new ProjectWithRuntimeClasspathNormalization(api).withFile sIgnored()
def ignoredResource = project[ignoredResourceName] def ignoredResource = project[ignoredResourceName]
def notIgnoredResource = project[notIgnoredResourceName] def notIgnoredResource = project[notIgnoredResourceName]
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
skipping to change at line 83 skipping to change at line 88
'directories' | 'ignoredResourceInDirectory' | 'notIgnoredRe sourceInDirectory' | Api.RUNTIME 'directories' | 'ignoredResourceInDirectory' | 'notIgnoredRe sourceInDirectory' | Api.RUNTIME
'jars' | 'ignoredResourceInJar' | 'notIgnoredRe sourceInJar' | Api.RUNTIME 'jars' | 'ignoredResourceInJar' | 'notIgnoredRe sourceInJar' | Api.RUNTIME
'nested jars' | 'ignoredResourceInNestedJar' | 'notIgnoredRe sourceInNestedJar' | Api.RUNTIME 'nested jars' | 'ignoredResourceInNestedJar' | 'notIgnoredRe sourceInNestedJar' | Api.RUNTIME
'nested in dir jars' | 'ignoredResourceInNestedInDirJar' | 'notIgnoredRe sourceInNestedInDirJar' | Api.RUNTIME 'nested in dir jars' | 'ignoredResourceInNestedInDirJar' | 'notIgnoredRe sourceInNestedInDirJar' | Api.RUNTIME
'directories' | 'ignoredResourceInDirectory' | 'notIgnoredRe sourceInDirectory' | Api.ANNOTATION 'directories' | 'ignoredResourceInDirectory' | 'notIgnoredRe sourceInDirectory' | Api.ANNOTATION
'jars' | 'ignoredResourceInJar' | 'notIgnoredRe sourceInJar' | Api.ANNOTATION 'jars' | 'ignoredResourceInJar' | 'notIgnoredRe sourceInJar' | Api.ANNOTATION
'nested jars' | 'ignoredResourceInNestedJar' | 'notIgnoredRe sourceInNestedJar' | Api.ANNOTATION 'nested jars' | 'ignoredResourceInNestedJar' | 'notIgnoredRe sourceInNestedJar' | Api.ANNOTATION
'nested in dir jars' | 'ignoredResourceInNestedInDirJar' | 'notIgnoredRe sourceInNestedInDirJar' | Api.ANNOTATION 'nested in dir jars' | 'ignoredResourceInNestedInDirJar' | 'notIgnoredRe sourceInNestedInDirJar' | Api.ANNOTATION
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization - see htt ps://github.com/gradle/gradle/issues/13706")
@Unroll @Unroll
def "can ignore manifest attributes in #tree on runtime classpath"() { def "can ignore manifest attributes in #tree on runtime classpath"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withManifestAttributesIgnored() def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withManifestAttributesIgnored()
def manifestResource = project[resourceName] def manifestResource = project[resourceName]
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
when: when:
manifestResource.replaceContents("Manifest-Version: 1.0\nImplementation- Version: 1.0.1") manifestResource.changeAttributes((IMPLEMENTATION_VERSION): "1.0.1")
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
where: where:
tree | resourceName tree | resourceName
'jar' | 'jarManifest' 'jar' | 'jarManifest'
'directory' | 'manifestInDirectory' 'directory' | 'manifestInDirectory'
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt ps://github.com/gradle/gradle/issues/13706")
@Unroll @Unroll
def "can ignore entire manifest in #tree on runtime classpath"() { def "can ignore entire manifest in #tree on runtime classpath"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withManifestIgnored() def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withManifestIgnored()
def manifestResource = project[resourceName] def manifestResource = project[resourceName]
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
when: when:
manifestResource.replaceContents("Manifest-Version: 1.0\nImplementation- Version: 1.0.1") manifestResource.changeAttributes((IMPLEMENTATION_VERSION): "1.0.1")
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
where: where:
tree | resourceName tree | resourceName
'jar' | 'jarManifest' 'jar' | 'jarManifest'
'directory' | 'manifestInDirectory' 'directory' | 'manifestInDirectory'
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt ps://github.com/gradle/gradle/issues/13706")
@Unroll @Unroll
def "can ignore all meta-inf files in #tree on runtime classpath"() { def "can ignore all meta-inf files in #tree on runtime classpath"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withAllMetaInfIgnored() def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withAllMetaInfIgnored()
def manifestResource = project[resourceName] def manifestResource = project[resourceName]
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
when: when:
manifestResource.replaceContents("Manifest-Version: 1.0\nImplementation- Version: 1.0.1") manifestResource.changeAttributes((IMPLEMENTATION_VERSION): "1.0.1")
project.jarManifestProperties.replaceContents("implementation-version=1. 0.1") project.jarManifestProperties.replaceContents("implementation-version=1. 0.1")
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
where: where:
tree | resourceName tree | resourceName
'jar' | 'jarManifest' 'jar' | 'jarManifest'
'directory' | 'manifestInDirectory' 'directory' | 'manifestInDirectory'
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt ps://github.com/gradle/gradle/issues/13706")
def "can ignore manifest properties on runtime classpath"() { def "can ignore manifest properties on runtime classpath"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withManifestPropertiesIgnored() def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME). withManifestPropertiesIgnored()
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
when: when:
project.jarManifestProperties.replaceContents("implementation-version=1. 0.1") project.jarManifestProperties.replaceContents("implementation-version=1. 0.1")
succeeds project.customTask succeeds project.customTask
then: then:
skipped(project.customTask) skipped(project.customTask)
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt
def "can configure ignore rules per project (using runtime API: #useRuntimeA ps://github.com/gradle/gradle/issues/13706")
pi)"() { def "can configure ignore rules per project (using runtime API: #api)"() {
def projectWithIgnores = new ProjectWithRuntimeClasspathNormalization('a ', api).withFilesIgnored() def projectWithIgnores = new ProjectWithRuntimeClasspathNormalization('a ', api).withFilesIgnored()
def projectWithoutIgnores = new ProjectWithRuntimeClasspathNormalization ('b', api) def projectWithoutIgnores = new ProjectWithRuntimeClasspathNormalization ('b', api)
def allProjects = [projectWithoutIgnores, projectWithIgnores] def allProjects = [projectWithoutIgnores, projectWithIgnores]
settingsFile << "include 'a', 'b'" settingsFile << "include 'a', 'b'"
when: when:
succeeds(*allProjects*.customTask) succeeds(*allProjects*.customTask)
then: then:
executedAndNotSkipped(*allProjects*.customTask) executedAndNotSkipped(*allProjects*.customTask)
skipping to change at line 238 skipping to change at line 244
when: when:
fails 'configureNormalization' fails 'configureNormalization'
then: then:
failureHasCause 'Cannot configure runtime classpath normalization after execution started.' failureHasCause 'Cannot configure runtime classpath normalization after execution started.'
where: where:
change | config | api change | config | api
'ignore file' | "ignore '**/some-other-file.txt'" | Api.RUNTIME 'ignore file' | "ignore '**/some-other-file.txt'" | Api.RUNTIME
'ignore file' | "ignore '**/some-other-file.txt'" | Api.ANNOTATION 'ignore file' | "ignore '**/some-other-file.txt'" | Api.ANNOTATION
'ignore manifest attribute' | "metaInf { ignoreAttribute 'Implementation 'ignore manifest attribute' | "metaInf { ignoreAttribute '${IMPLEMENTATI
-version' }" | Api.RUNTIME ON_VERSION}' }" | Api.RUNTIME
'ignore manifest attribute' | "metaInf { ignoreAttribute 'Implementation 'ignore manifest attribute' | "metaInf { ignoreAttribute '${IMPLEMENTATI
-version' }" | Api.ANNOTATION ON_VERSION}' }" | Api.ANNOTATION
'ignore property' | "properties { ignoreProperty 'timestamp' } " | Api.RUNTIME 'ignore property' | "properties { ignoreProperty 'timestamp' } " | Api.RUNTIME
'ignore property' | "properties { ignoreProperty 'timestamp' } " | Api.ANNOTATION 'ignore property' | "properties { ignoreProperty 'timestamp' } " | Api.ANNOTATION
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt
def "can ignore properties on runtime classpath in #tree (using runtime API: ps://github.com/gradle/gradle/issues/13706")
#useRuntimeApi)"() { def "can ignore properties on runtime classpath in #tree (using runtime API:
#api)"() {
def project = new ProjectWithRuntimeClasspathNormalization(api).withProp ertiesIgnored() def project = new ProjectWithRuntimeClasspathNormalization(api).withProp ertiesIgnored()
def ignoredResource = project[ignoredResourceName] def ignoredResource = project[ignoredResourceName]
when: when:
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
when: when:
skipping to change at line 284 skipping to change at line 290
'directories' | 'propertiesFileInDir' | Api.RUNTIME 'directories' | 'propertiesFileInDir' | Api.RUNTIME
'jars' | 'propertiesFileInJar' | Api.RUNTIME 'jars' | 'propertiesFileInJar' | Api.RUNTIME
'nested jars' | 'propertiesFileInNestedJar' | Api.RUNTIME 'nested jars' | 'propertiesFileInNestedJar' | Api.RUNTIME
'nested in dir jars' | 'propertiesFileInNestedInDirJar' | Api.RUNTIME 'nested in dir jars' | 'propertiesFileInNestedInDirJar' | Api.RUNTIME
'directories' | 'propertiesFileInDir' | Api.ANNOTATION 'directories' | 'propertiesFileInDir' | Api.ANNOTATION
'jars' | 'propertiesFileInJar' | Api.ANNOTATION 'jars' | 'propertiesFileInJar' | Api.ANNOTATION
'nested jars' | 'propertiesFileInNestedJar' | Api.ANNOTATION 'nested jars' | 'propertiesFileInNestedJar' | Api.ANNOTATION
'nested in dir jars' | 'propertiesFileInNestedInDirJar' | Api.ANNOTATION 'nested in dir jars' | 'propertiesFileInNestedInDirJar' | Api.ANNOTATION
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt ps://github.com/gradle/gradle/issues/13706")
def "can ignore properties in selected files"() { def "can ignore properties in selected files"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME) def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME)
def notIgnoredPropertiesFile = new PropertiesResource(project.root.file( 'classpath/dirEntry/bar.properties'), [(IGNORE_ME_TOO): 'this should not actuall y be ignored']) def notIgnoredPropertiesFile = new PropertiesResource(project.root.file( 'classpath/dirEntry/bar.properties'), [(IGNORE_ME_TOO): 'this should not actuall y be ignored'])
project.buildFile << """ project.buildFile << """
normalization { normalization {
runtimeClasspath { runtimeClasspath {
properties('**/foo.properties') { properties('**/foo.properties') {
ignoreProperty '${IGNORE_ME}' ignoreProperty '${IGNORE_ME}'
} }
} }
skipping to change at line 321 skipping to change at line 327
then: then:
skipped(project.customTask) skipped(project.customTask)
when: when:
notIgnoredPropertiesFile.changeProperty(IGNORE_ME, 'please dont ignore m e') notIgnoredPropertiesFile.changeProperty(IGNORE_ME, 'please dont ignore m e')
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt ps://github.com/gradle/gradle/issues/13706")
def "can ignore properties in selected files defined in multiple rules"() { def "can ignore properties in selected files defined in multiple rules"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME) def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME)
def notIgnoredPropertiesFile = new PropertiesResource(project.root.file( 'classpath/dirEntry/bar.properties'), [(IGNORE_ME_TOO): 'this should not actuall y be ignored']) def notIgnoredPropertiesFile = new PropertiesResource(project.root.file( 'classpath/dirEntry/bar.properties'), [(IGNORE_ME_TOO): 'this should not actuall y be ignored'])
project.propertiesFileInDir.changeProperty(IGNORE_ME_TOO, 'this should a lso be ignored') project.propertiesFileInDir.changeProperty(IGNORE_ME_TOO, 'this should a lso be ignored')
project.buildFile << """ project.buildFile << """
normalization { normalization {
runtimeClasspath { runtimeClasspath {
properties('**/foo.properties') { properties('**/foo.properties') {
ignoreProperty '${IGNORE_ME}' ignoreProperty '${IGNORE_ME}'
} }
skipping to change at line 406 skipping to change at line 412
then: then:
skipped(project.customTask) skipped(project.customTask)
when: when:
project.propertiesFileInDir.changeProperty('foo', 'baz') project.propertiesFileInDir.changeProperty('foo', 'baz')
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization") @ToBeFixedForConfigurationCache(because = "classpath normalization - see htt ps://github.com/gradle/gradle/issues/13706")
def "can add rules to the default properties rule"() { def "can add rules to the default properties rule"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME) def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME)
def notIgnoredPropertiesFile = new PropertiesResource(project.root.file( 'classpath/dirEntry/bar.properties'), [(IGNORE_ME): 'this should not actually be ignored']) def notIgnoredPropertiesFile = new PropertiesResource(project.root.file( 'classpath/dirEntry/bar.properties'), [(IGNORE_ME): 'this should not actually be ignored'])
project.propertiesFileInDir.changeProperty(IGNORE_ME_TOO, 'this should a lso be ignored') project.propertiesFileInDir.changeProperty(IGNORE_ME_TOO, 'this should a lso be ignored')
project.buildFile << """ project.buildFile << """
normalization { normalization {
runtimeClasspath { runtimeClasspath {
properties('**/foo.properties') { properties('**/foo.properties') {
ignoreProperty '${IGNORE_ME}' ignoreProperty '${IGNORE_ME}'
} }
skipping to change at line 469 skipping to change at line 475
then: then:
skipped(project.customTask) skipped(project.customTask)
when: when:
project.propertiesFileInDir.backingFile.text = 'propertyWithBadValue=thi s is also a bad unicode sequence \\uyyyy' project.propertiesFileInDir.backingFile.text = 'propertyWithBadValue=thi s is also a bad unicode sequence \\uyyyy'
succeeds project.customTask succeeds project.customTask
then: then:
executedAndNotSkipped(project.customTask) executedAndNotSkipped(project.customTask)
} }
@ToBeFixedForConfigurationCache(because = "classpath normalization - see htt
ps://github.com/gradle/gradle/issues/13706")
@Issue('https://github.com/gradle/gradle/issues/16144')
def "changing normalization configuration rules changes build cache key (#de
scription)"() {
def project = new ProjectWithRuntimeClasspathNormalization(Api.RUNTIME)
project.propertiesFileInJar.changeProperty(ALSO_IGNORE_ME, 'some value')
// We implement this with a flag, rather than just changing the build sc
ript, because we don't want the change in build script to affect
// the cache hit. We want the only change to be in the normalization rul
es so we can be sure that's what's changing the cache key.
project.buildFile << """
normalization {
runtimeClasspath {
if (project.hasProperty('${enableFilterFlag}')) {
${normalizationRule}
}
}
}
"""
when:
args('--build-cache')
succeeds 'clean', project.customTask
then:
executedAndNotSkipped(project.customTask)
when:
args("-P${enableFilterFlag}", '--build-cache')
succeeds 'clean', project.customTask
then:
executedAndNotSkipped(project.customTask)
where:
enableFilterFlag | normalizationRule
| description
PROPERTIES_FILTER_FLAG | "properties('**/foo.properties') { ignorePrope
rty '${ALSO_IGNORE_ME}' }" | 'properties rule'
META_INF_FILTER_FLAG | "metaInf { ignoreAttribute '${IMPLEMENTATION_V
ERSION}' }" | 'meta-inf rule'
FILE_FILTER_FLAG | "ignore '**/ignored.txt'"
| 'ignore rule'
}
static final String IGNORE_ME = 'ignore-me' static final String IGNORE_ME = 'ignore-me'
static final String ALSO_IGNORE_ME = 'also-ignore-me'
static final String IGNORE_ME_TOO = 'ignore-me-too' static final String IGNORE_ME_TOO = 'ignore-me-too'
static final String DONT_IGNORE_ME = 'dont-ignore-me' static final String DONT_IGNORE_ME = 'dont-ignore-me'
static final String IMPLEMENTATION_VERSION = Attributes.Name.IMPLEMENTATION_
VERSION.toString()
static final String PROPERTIES_FILTER_FLAG = "filterProperties"
static final String META_INF_FILTER_FLAG = "filterMetaInf"
static final String FILE_FILTER_FLAG = "filterFile"
enum Api { enum Api {
RUNTIME, ANNOTATION RUNTIME, ANNOTATION
} }
class ProjectWithRuntimeClasspathNormalization { class ProjectWithRuntimeClasspathNormalization {
final TestFile root final TestFile root
final TestFile buildCacheDir
TestResource ignoredResourceInDirectory TestResource ignoredResourceInDirectory
TestResource notIgnoredResourceInDirectory TestResource notIgnoredResourceInDirectory
TestResource ignoredResourceInJar TestResource ignoredResourceInJar
TestResource ignoredResourceInNestedJar TestResource ignoredResourceInNestedJar
TestResource ignoredResourceInNestedInDirJar TestResource ignoredResourceInNestedInDirJar
TestResource notIgnoredResourceInJar TestResource notIgnoredResourceInJar
TestResource notIgnoredResourceInNestedJar TestResource notIgnoredResourceInNestedJar
TestResource notIgnoredResourceInNestedInDirJar TestResource notIgnoredResourceInNestedInDirJar
TestResource jarManifest ManifestResource jarManifest
TestResource jarManifestProperties TestResource jarManifestProperties
TestResource manifestInDirectory ManifestResource manifestInDirectory
PropertiesResource propertiesFileInDir PropertiesResource propertiesFileInDir
PropertiesResource propertiesFileInJar PropertiesResource propertiesFileInJar
PropertiesResource propertiesFileInNestedJar PropertiesResource propertiesFileInNestedJar
PropertiesResource propertiesFileInNestedInDirJar PropertiesResource propertiesFileInNestedInDirJar
TestFile libraryJar TestFile libraryJar
TestFile nestedJar TestFile nestedJar
TestFile nestedInDirJar TestFile nestedInDirJar
private TestFile libraryJarContents private TestFile libraryJarContents
private TestFile nestedJarContents private TestFile nestedJarContents
private TestFile nestedInDirJarContents private TestFile nestedInDirJarContents
private final String projectName private final String projectName
final TestFile buildFile final TestFile buildFile
final TestFile settingsFile
ProjectWithRuntimeClasspathNormalization(String projectName = null, Api api) { ProjectWithRuntimeClasspathNormalization(String projectName = null, Api api) {
this.projectName = projectName this.projectName = projectName
this.root = projectName ? file(projectName) : temporaryFolder.testDi rectory this.root = projectName ? file(projectName) : temporaryFolder.testDi rectory
this.buildCacheDir = testDirectory.file("build-cache")
def buildCachePath = TextUtil.normaliseFileSeparators(buildCacheDir.
absolutePath)
settingsFile = root.file('settings.gradle') << """
buildCache {
local {
directory = file('${buildCachePath}')
}
}
"""
buildFile = root.file('build.gradle') << """ buildFile = root.file('build.gradle') << """
apply plugin: 'base' apply plugin: 'base'
""" """
buildFile << declareCustomTask(api) buildFile << declareCustomTask(api)
nestedInDirJarContents = root.file('nestedInDirJarContents').create { nestedInDirJarContents = root.file('nestedInDirJarContents').create {
ignoredResourceInNestedInDirJar = new TestResource(file('another /package/ignored.txt') << "This should be ignored", this.&createNestedInDirJar) ignoredResourceInNestedInDirJar = new TestResource(file('another /package/ignored.txt') << "This should be ignored", this.&createNestedInDirJar)
notIgnoredResourceInNestedInDirJar = new TestResource(file('anot her/package/not-ignored.txt') << "This should not be ignored", this.&createNeste dInDirJar) notIgnoredResourceInNestedInDirJar = new TestResource(file('anot her/package/not-ignored.txt') << "This should not be ignored", this.&createNeste dInDirJar)
propertiesFileInNestedInDirJar = new PropertiesResource(file('so me/path/to/foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNOR E_ME): 'this should not be ignored'], this.&createNestedInDirJar) propertiesFileInNestedInDirJar = new PropertiesResource(file('so me/path/to/foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNOR E_ME): 'this should not be ignored'], this.&createNestedInDirJar)
} }
root.file('classpath/dirEntry').create { root.file('classpath/dirEntry').create {
ignoredResourceInDirectory = new TestResource(file("ignored.txt" ) << "This should be ignored") ignoredResourceInDirectory = new TestResource(file("ignored.txt" ) << "This should be ignored")
notIgnoredResourceInDirectory = new TestResource(file("not-ignor ed.txt") << "This should not be ignored") notIgnoredResourceInDirectory = new TestResource(file("not-ignor ed.txt") << "This should not be ignored")
nestedInDirJar = file('nestedInDir.jar') nestedInDirJar = file('nestedInDir.jar')
propertiesFileInDir = new PropertiesResource(file('some/path/to/ foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNORE_ME): 'thi s should not be ignored']) propertiesFileInDir = new PropertiesResource(file('some/path/to/ foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNORE_ME): 'thi s should not be ignored'])
manifestInDirectory = new TestResource(file('META-INF/MANIFEST.M F') << "Manifest-Version: 1.0\nImplementation-Version: 1.0.0") manifestInDirectory = new ManifestResource(file('META-INF/MANIFE ST.MF')).withAttributes((IMPLEMENTATION_VERSION): "1.0.0")
} }
nestedJarContents = root.file('libraryContents').create { nestedJarContents = root.file('libraryContents').create {
ignoredResourceInNestedJar = new TestResource(file('some/package /ignored.txt') << "This should be ignored", this.&createJar) ignoredResourceInNestedJar = new TestResource(file('some/package /ignored.txt') << "This should be ignored", this.&createJar)
notIgnoredResourceInNestedJar = new TestResource(file('some/pack age/not-ignored.txt') << "This should not be ignored", this.&createJar) notIgnoredResourceInNestedJar = new TestResource(file('some/pack age/not-ignored.txt') << "This should not be ignored", this.&createJar)
propertiesFileInNestedJar = new PropertiesResource(file('some/pa th/to/foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNORE_ME) : 'this should not be ignored'], this.&createJar) propertiesFileInNestedJar = new PropertiesResource(file('some/pa th/to/foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNORE_ME) : 'this should not be ignored'], this.&createJar)
} }
libraryJarContents = root.file('libraryContents').create { libraryJarContents = root.file('libraryContents').create {
jarManifest = new TestResource(file('META-INF/MANIFEST.MF') << " Manifest-Version: 1.0\nImplementation-Version: 1.0.0", this.&createJar) jarManifest = new ManifestResource(file('META-INF/MANIFEST.MF'), this.&createJar).withAttributes((IMPLEMENTATION_VERSION): "1.0.0")
jarManifestProperties = new TestResource(file('META-INF/build-in fo.properties') << "implementation-version=1.0.0", this.&createJar) jarManifestProperties = new TestResource(file('META-INF/build-in fo.properties') << "implementation-version=1.0.0", this.&createJar)
ignoredResourceInJar = new TestResource(file('some/package/ignor ed.txt') << "This should be ignored", this.&createJar) ignoredResourceInJar = new TestResource(file('some/package/ignor ed.txt') << "This should be ignored", this.&createJar)
notIgnoredResourceInJar = new TestResource(file('some/package/no t-ignored.txt') << "This should not be ignored", this.&createJar) notIgnoredResourceInJar = new TestResource(file('some/package/no t-ignored.txt') << "This should not be ignored", this.&createJar)
nestedJar = file('nested.jar') nestedJar = file('nested.jar')
propertiesFileInJar = new PropertiesResource(file('some/path/to/ foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNORE_ME): 'thi s should not be ignored'], this.&createJar) propertiesFileInJar = new PropertiesResource(file('some/path/to/ foo.properties'), [(IGNORE_ME): 'this should be ignored', (DONT_IGNORE_ME): 'thi s should not be ignored'], this.&createJar)
} }
libraryJar = root.file('library.jar') libraryJar = root.file('library.jar')
createJar() createJar()
createNestedInDirJar() createNestedInDirJar()
} }
skipping to change at line 553 skipping to change at line 614
String declareCustomTask(Api api) { String declareCustomTask(Api api) {
if (api == Api.RUNTIME) { if (api == Api.RUNTIME) {
return """ return """
task customTask { task customTask {
def outputFile = file("\$temporaryDir/output.txt") def outputFile = file("\$temporaryDir/output.txt")
inputs.files("classpath/dirEntry", "library.jar") inputs.files("classpath/dirEntry", "library.jar")
.withPropertyName("classpath") .withPropertyName("classpath")
.withNormalizer(ClasspathNormalizer) .withNormalizer(ClasspathNormalizer)
outputs.file(outputFile) outputs.file(outputFile)
.withPropertyName("outputFile") .withPropertyName("outputFile")
outputs.cacheIf { true }
doLast { doLast {
outputFile.text = "done" outputFile.text = "done"
} }
} }
""" """
} else { } else {
return """ return """
@CacheableTask
class CustomTask extends DefaultTask { class CustomTask extends DefaultTask {
@OutputFile File outputFile = new File(temporaryDir, "ou tput.txt") @OutputFile File outputFile = new File(temporaryDir, "ou tput.txt")
@Classpath FileCollection classpath = project.layout.fil es("classpath/dirEntry", "library.jar") @Classpath FileCollection classpath = project.layout.fil es("classpath/dirEntry", "library.jar")
@TaskAction void generate() { @TaskAction void generate() {
outputFile.text = "done" outputFile.text = "done"
} }
} }
task customTask(type: CustomTask) task customTask(type: CustomTask)
skipping to change at line 635 skipping to change at line 698
} }
""".stripIndent() """.stripIndent()
return this return this
} }
ProjectWithRuntimeClasspathNormalization withManifestAttributesIgnored() { ProjectWithRuntimeClasspathNormalization withManifestAttributesIgnored() {
root.file('build.gradle') << """ root.file('build.gradle') << """
normalization { normalization {
runtimeClasspath { runtimeClasspath {
metaInf { metaInf {
ignoreAttribute "Implementation-Version" ignoreAttribute "${IMPLEMENTATION_VERSION}"
} }
} }
} }
""".stripIndent() """.stripIndent()
return this return this
} }
ProjectWithRuntimeClasspathNormalization withManifestPropertiesIgnored() { ProjectWithRuntimeClasspathNormalization withManifestPropertiesIgnored() {
root.file('build.gradle') << """ root.file('build.gradle') << """
normalization { normalization {
skipping to change at line 710 skipping to change at line 773
void add() { void add() {
backingFile << "First creation of file" backingFile << "First creation of file"
changed() changed()
} }
void changed() { void changed() {
onChange.call() onChange.call()
} }
} }
class ManifestResource extends TestResource {
Map<String, String> attributes
ManifestResource(TestFile backingFile, Closure onChange = {}) {
super(backingFile, onChange)
}
ManifestResource withAttributes(Map<String, String> attributes) {
this.attributes = attributes
def manifest = new Manifest()
def mainAttributes = manifest.getMainAttributes()
mainAttributes.put(Attributes.Name.MANIFEST_VERSION, "1.0")
attributes.each {name, value ->
mainAttributes.put(new Attributes.Name(name), value)
}
backingFile.withOutputStream {os ->
manifest.write(os)
}
return this
}
ManifestResource changeAttributes(Map<String, String> attributes) {
withAttributes(attributes)
changed()
return this
}
@Override
void changeContents() {
throw new UnsupportedOperationException()
}
@Override
void add() {
throw new UnsupportedOperationException()
}
}
class PropertiesResource extends TestResource { class PropertiesResource extends TestResource {
String comment = "" String comment = ""
PropertiesResource(TestFile backingFile, Map<String, String> initialProp s, Closure finalizedBy={}) { PropertiesResource(TestFile backingFile, Map<String, String> initialProp s, Closure finalizedBy={}) {
super(backingFile, finalizedBy) super(backingFile, finalizedBy)
withProperties() { Properties props -> withProperties() { Properties props ->
props.putAll(initialProps) props.putAll(initialProps)
} }
} }
 End of changes. 30 change blocks. 
27 lines changed or deleted 140 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)