Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert functional test kits to Kotlin #1087

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ val intiTestRuntimeOnly: Configuration by configurations.getting {
val funcTest: SourceSet by sourceSets.creating
val funcTestImplementation: Configuration by configurations.getting {
extendsFrom(configurations.testImplementation.get())
// TODO: this will be removed after we migrated all functional tests to Kotlin.
extendsFrom(intiTestImplementation)
}
val funcTestRuntimeOnly: Configuration by configurations.getting {
extendsFrom(configurations.testRuntimeOnly.get())
Expand Down Expand Up @@ -88,6 +90,10 @@ dependencies {
funcTestImplementation(sourceSets.main.get().output)
funcTestImplementation(intiTest.output)

intiTestImplementation(libs.okio)
intiTestImplementation(libs.apache.maven.modelBuilder)
intiTestImplementation(libs.apache.maven.repositoryMetadata)

lintChecks(libs.androidx.gradlePluginLints)
lintChecks(libs.assertk.lint)
}
Expand Down
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
[versions]
maven = "3.9.9"

[libraries]
apache-ant = "org.apache.ant:ant:1.10.15"
apache-commonsIo = "commons-io:commons-io:2.18.0"
apache-commonsLang = "org.apache.commons:commons-lang3:3.17.0"
apache-log4j = "org.apache.logging.log4j:log4j-core:2.24.3"
apache-maven-modelBuilder = { module = "org.apache.maven:maven-model-builder", version.ref = "maven" }
apache-maven-repositoryMetadata = { module = "org.apache.maven:maven-repository-metadata", version.ref = "maven" }
asm = "org.ow2.asm:asm-commons:9.7.1"
jdependency = "org.vafer:jdependency:2.11"
jdom2 = "org.jdom:jdom2:2.0.6.1"
plexus-utils = "org.codehaus.plexus:plexus-utils:4.0.2"
plexus-xml = "org.codehaus.plexus:plexus-xml:4.0.4"
xmlunit = "org.xmlunit:xmlunit-legacy:2.10.0"
okio = "com.squareup.okio:okio:3.9.1"

pluginPublish = "com.gradle.publish:plugin-publish-plugin:1.3.0"
mavenPublish = "com.vanniktech:gradle-maven-publish-plugin:0.30.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification
import org.apache.tools.zip.ZipFile
import org.gradle.testkit.runner.BuildResult
import spock.lang.Issue

import java.util.jar.Attributes
import java.util.jar.JarFile

class ApplicationSpec extends PluginSpecification {
class ApplicationSpec extends BasePluginSpecification {

def 'integration with application plugin'() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.jengelman.gradle.plugins.shadow.util
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.util.AppendableJar
import com.github.jengelman.gradle.plugins.shadow.util.AppendableMavenFileRepository
import org.codehaus.plexus.util.IOUtil
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
Expand All @@ -11,7 +13,7 @@ import java.util.function.Function
import java.util.jar.JarEntry
import java.util.jar.JarFile

abstract class PluginSpecification extends Specification {
abstract class BasePluginSpecification extends Specification {

@TempDir
Path dir
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification

class ConfigurationCacheSpec extends PluginSpecification {
class ConfigurationCacheSpec extends BasePluginSpecification {

@Override
def setup() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification


class ConfigureShadowRelocationSpec extends PluginSpecification {
class ConfigureShadowRelocationSpec extends BasePluginSpecification {

def "auto relocate plugin dependencies"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Ignore
import spock.lang.Issue

class FilteringSpec extends PluginSpecification {
class FilteringSpec extends BasePluginSpecification {

@Override
def setup() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.util.AppendableMavenFileRepository
import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification
import groovy.json.JsonSlurper
import groovy.xml.XmlSlurper
import org.gradle.api.attributes.Bundling
import org.gradle.api.attributes.Usage
import spock.lang.Issue

class PublishingSpec extends PluginSpecification {
class PublishingSpec extends BasePluginSpecification {

AppendableMavenFileRepository publishingRepo

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification
import spock.lang.Ignore
import spock.lang.Issue

import java.util.jar.Attributes
import java.util.jar.JarFile

class RelocationSpec extends PluginSpecification {
class RelocationSpec extends BasePluginSpecification {

@Issue('SHADOW-58')
def "relocate dependency files"() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +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.PluginSpecification
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
Expand All @@ -17,7 +16,7 @@ import spock.lang.Unroll
import java.util.jar.Attributes
import java.util.jar.JarFile

class ShadowPluginSpec extends PluginSpecification {
class ShadowPluginSpec extends BasePluginSpecification {

def 'apply plugin'() {
given:
Expand Down Expand Up @@ -63,7 +62,7 @@ class ShadowPluginSpec extends PluginSpecification {
@Unroll
def 'Compatible with Gradle #version'() {
given:
File one = buildJar('one.jar').insertFile('META-INF/services/shadow.Shadow',
File one = buildJar('one.jar').insert('META-INF/services/shadow.Shadow',
'one # NOTE: No newline terminates this line/file').write()

repo.module('shadow', 'two', '1.0').insertFile('META-INF/services/shadow.Shadow',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransfor
import com.github.jengelman.gradle.plugins.shadow.transformers.GroovyExtensionModuleTransformer
import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
import com.github.jengelman.gradle.plugins.shadow.transformers.XmlAppendingTransformer
import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification
import spock.lang.Issue
import spock.lang.Unroll

import java.util.jar.JarInputStream
import java.util.jar.Manifest

class TransformerSpec extends PluginSpecification {
class TransformerSpec extends BasePluginSpecification {

def 'service resource transformer'() {
given:
File one = buildJar('one.jar')
.insertFile('META-INF/services/org.apache.maven.Shade',
.insert('META-INF/services/org.apache.maven.Shade',
'one # NOTE: No newline terminates this line/file')
.insertFile('META-INF/services/com.acme.Foo', 'one')
.insert('META-INF/services/com.acme.Foo', 'one')
.write()

File two = buildJar('two.jar')
.insertFile('META-INF/services/org.apache.maven.Shade',
.insert('META-INF/services/org.apache.maven.Shade',
'two # NOTE: No newline terminates this line/file')
.insertFile('META-INF/services/com.acme.Foo', 'two')
.insert('META-INF/services/com.acme.Foo', 'two')
.write()

buildFile << """
Expand Down Expand Up @@ -61,10 +60,10 @@ two # NOTE: No newline terminates this line/file'''.stripIndent()

def 'service resource transformer alternate path'() {
given:
File one = buildJar('one.jar').insertFile('META-INF/foo/org.apache.maven.Shade',
File one = buildJar('one.jar').insert('META-INF/foo/org.apache.maven.Shade',
'one # NOTE: No newline terminates this line/file').write()

File two = buildJar('two.jar').insertFile('META-INF/foo/org.apache.maven.Shade',
File two = buildJar('two.jar').insert('META-INF/foo/org.apache.maven.Shade',
'two # NOTE: No newline terminates this line/file').write()

buildFile << """
Expand Down Expand Up @@ -97,15 +96,15 @@ two # NOTE: No newline terminates this line/file'''.stripIndent()
def 'service resource transformer short syntax'() {
given:
File one = buildJar('one.jar')
.insertFile('META-INF/services/org.apache.maven.Shade',
.insert('META-INF/services/org.apache.maven.Shade',
'one # NOTE: No newline terminates this line/file')
.insertFile('META-INF/services/com.acme.Foo', 'one')
.insert('META-INF/services/com.acme.Foo', 'one')
.write()

File two = buildJar('two.jar')
.insertFile('META-INF/services/org.apache.maven.Shade',
.insert('META-INF/services/org.apache.maven.Shade',
'two # NOTE: No newline terminates this line/file')
.insertFile('META-INF/services/com.acme.Foo', 'two')
.insert('META-INF/services/com.acme.Foo', 'two')
.write()

buildFile << """
Expand Down Expand Up @@ -142,22 +141,22 @@ two # NOTE: No newline terminates this line/file'''.stripIndent()
def 'service resource transformer short syntax relocation'() {
given:
File one = buildJar('one.jar')
.insertFile('META-INF/services/java.sql.Driver',
.insert('META-INF/services/java.sql.Driver',
'''oracle.jdbc.OracleDriver
org.apache.hive.jdbc.HiveDriver'''.stripIndent())
.insertFile('META-INF/services/org.apache.axis.components.compiler.Compiler',
.insert('META-INF/services/org.apache.axis.components.compiler.Compiler',
'org.apache.axis.components.compiler.Javac')
.insertFile('META-INF/services/org.apache.commons.logging.LogFactory',
.insert('META-INF/services/org.apache.commons.logging.LogFactory',
'org.apache.commons.logging.impl.LogFactoryImpl')
.write()

File two = buildJar('two.jar')
.insertFile('META-INF/services/java.sql.Driver',
.insert('META-INF/services/java.sql.Driver',
'''org.apache.derby.jdbc.AutoloadedDriver
com.mysql.jdbc.Driver'''.stripIndent())
.insertFile('META-INF/services/org.apache.axis.components.compiler.Compiler',
.insert('META-INF/services/org.apache.axis.components.compiler.Compiler',
'org.apache.axis.components.compiler.Jikes')
.insertFile('META-INF/services/org.apache.commons.logging.LogFactory',
.insert('META-INF/services/org.apache.commons.logging.LogFactory',
'org.mortbay.log.Factory')
.write()

Expand Down Expand Up @@ -207,10 +206,10 @@ org.mortbay.log.Factory'''.stripIndent()

def 'service resource transformer short syntax alternate path'() {
given:
File one = buildJar('one.jar').insertFile('META-INF/foo/org.apache.maven.Shade',
File one = buildJar('one.jar').insert('META-INF/foo/org.apache.maven.Shade',
'one # NOTE: No newline terminates this line/file').write()

File two = buildJar('two.jar').insertFile('META-INF/foo/org.apache.maven.Shade',
File two = buildJar('two.jar').insert('META-INF/foo/org.apache.maven.Shade',
'two # NOTE: No newline terminates this line/file').write()

buildFile << """
Expand Down Expand Up @@ -240,7 +239,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent()
@Issue(['SHADOW-70', 'SHADOW-71'])
def 'apply transformers to project resources'() {
given:
File one = buildJar('one.jar').insertFile('META-INF/services/shadow.Shadow',
File one = buildJar('one.jar').insert('META-INF/services/shadow.Shadow',
'one # NOTE: No newline terminates this line/file').write()

repo.module('shadow', 'two', '1.0').insertFile('META-INF/services/shadow.Shadow',
Expand Down Expand Up @@ -277,10 +276,10 @@ two # NOTE: No newline terminates this line/file'''.stripIndent()

def 'appending transformer'() {
given:
File one = buildJar('one.jar').insertFile('test.properties',
File one = buildJar('one.jar').insert('test.properties',
'one # NOTE: No newline terminates this line/file').write()

File two = buildJar('two.jar').insertFile('test.properties',
File two = buildJar('two.jar').insert('test.properties',
'two # NOTE: No newline terminates this line/file').write()

buildFile << """
Expand Down Expand Up @@ -313,10 +312,10 @@ two # NOTE: No newline terminates this line/file

def 'appending transformer short syntax'() {
given:
File one = buildJar('one.jar').insertFile('test.properties',
File one = buildJar('one.jar').insert('test.properties',
'one # NOTE: No newline terminates this line/file').write()

File two = buildJar('two.jar').insertFile('test.properties',
File two = buildJar('two.jar').insert('test.properties',
'two # NOTE: No newline terminates this line/file').write()

buildFile << """
Expand Down Expand Up @@ -428,7 +427,7 @@ two # NOTE: No newline terminates this line/file

def 'append xml files'() {
given:
File xml1 = buildJar('xml1.jar').insertFile('properties.xml',
File xml1 = buildJar('xml1.jar').insert('properties.xml',
'''<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">

<properties version="1.0">
Expand All @@ -437,7 +436,7 @@ two # NOTE: No newline terminates this line/file
'''.stripIndent()
).write()

File xml2 = buildJar('xml2.jar').insertFile('properties.xml',
File xml2 = buildJar('xml2.jar').insert('properties.xml',
'''<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">

<properties version="1.0">
Expand Down Expand Up @@ -602,14 +601,14 @@ two # NOTE: No newline terminates this line/file
def 'Groovy extension module transformer'() {
given:
def one = buildJar('one.jar')
.insertFile('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
.insert('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
'''moduleName=foo
moduleVersion=1.0.5
extensionClasses=com.acme.foo.FooExtension,com.acme.foo.BarExtension
staticExtensionClasses=com.acme.foo.FooStaticExtension'''.stripIndent()).write()

def two = buildJar('two.jar')
.insertFile('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
.insert('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
'''moduleName=bar
moduleVersion=2.3.5
extensionClasses=com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension
Expand Down Expand Up @@ -646,14 +645,14 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write(
def 'Groovy extension module transformer works for Groovy2_5+'() {
given:
def one = buildJar('one.jar')
.insertFile('META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule',
.insert('META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule',
'''moduleName=foo
moduleVersion=1.0.5
extensionClasses=com.acme.foo.FooExtension,com.acme.foo.BarExtension
staticExtensionClasses=com.acme.foo.FooStaticExtension'''.stripIndent()).write()

def two = buildJar('two.jar')
.insertFile('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
.insert('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
'''moduleName=bar
moduleVersion=2.3.5
extensionClasses=com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension
Expand Down Expand Up @@ -691,14 +690,14 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write(
def 'Groovy extension module transformer short syntax'() {
given:
def one = buildJar('one.jar')
.insertFile('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
.insert('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
'''moduleName=foo
moduleVersion=1.0.5
extensionClasses=com.acme.foo.FooExtension,com.acme.foo.BarExtension
staticExtensionClasses=com.acme.foo.FooStaticExtension'''.stripIndent()).write()

def two = buildJar('two.jar')
.insertFile('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
.insert('META-INF/services/org.codehaus.groovy.runtime.ExtensionModule',
'''moduleName=bar
moduleVersion=2.3.5
extensionClasses=com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.jengelman.gradle.plugins.shadow.caching

import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification
import com.github.jengelman.gradle.plugins.shadow.BasePluginSpecification
import org.apache.commons.io.FileUtils
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
Expand All @@ -11,7 +11,7 @@ import java.nio.file.Path
import static org.gradle.testkit.runner.TaskOutcome.FROM_CACHE
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS

abstract class AbstractCachingSpec extends PluginSpecification {
abstract class AbstractCachingSpec extends BasePluginSpecification {
@TempDir
Path alternateDir

Expand Down
Loading
Loading