diff --git a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy index 19abff5588..e673f79976 100644 --- a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy +++ b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy @@ -35,21 +35,19 @@ abstract class AccurestIntegrationSpec extends Specification { protected void setupForProject(String projectRoot) { copyResourcesToRoot(projectRoot) - def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt") - if (pluginClasspathResource == null) { - throw new IllegalStateException("Did not find 'plugin-classpath.txt'") - } - String pluginClasspath = pluginClasspathResource.readLines() - .collect { it.replace('\\', '\\\\') } // escape backslashes in Windows paths - .collect { "'$it'" } - .join(", ") - buildFile << """ + String accurestGradlePluginLibsDir = System.getProperty("accurest-gradle-plugin-libs-dir").replace('\\', '\\\\') + String messagingLibDir = System.getProperty("messaging-libs-dir").replace('\\', '\\\\') + + buildFile.write """ + ext.messagingLibsDir = '$messagingLibDir' + buildscript { dependencies { - classpath files($pluginClasspath) + classpath fileTree(dir: '$accurestGradlePluginLibsDir', include: '*.jar') } } - """ + + """ + buildFile.text // Extending buildscript is required when 'apply' is used. // 'GradleRunner#withPluginClasspath' can be used when plugin is added using 'plugins { id...' } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle index cb15b57e01..a4a2ae6524 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle @@ -3,10 +3,6 @@ buildscript { mavenLocal() mavenCentral() } - dependencies { - // will be passed via classpath - // classpath "io.codearte.accurest:accurest-gradle-plugin:+" - } } apply plugin: 'groovy' @@ -53,8 +49,8 @@ dependencies { compile 'org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE' compile 'org.springframework.boot:spring-boot-starter-actuator:1.3.3.RELEASE' compile 'org.springframework.boot:spring-boot-starter-integration:1.3.3.RELEASE' - // will be passed via classpath (I have issues with doing that quite frankly) - compile 'io.codearte.accurest:accurest-messaging-integration:+' + + compile fileTree(dir: messagingLibsDir, include: '*.jar') testCompile "org.spockframework:spock-spring:1.0-groovy-2.4" testCompile 'org.springframework.boot:spring-boot-starter-test:1.3.3.RELEASE' diff --git a/build.gradle b/build.gradle index 27162e754c..0b99857e57 100644 --- a/build.gradle +++ b/build.gradle @@ -126,6 +126,15 @@ project(':accurest-converters') { } project(':accurest-gradle-plugin') { + + ext.messagingLibsDir ="$buildDir/messaging-libs" + ext.accurestGradlePluginLibsDir ="$buildDir/accurest-gradle-plugin-libs" + + ext.testSystemProperties = [ + 'accurest-gradle-plugin-libs-dir': accurestGradlePluginLibsDir, + 'messaging-libs-dir': messagingLibsDir + ] + dependencies { compile project(':accurest-core') compile project(':accurest-converters') @@ -135,51 +144,52 @@ project(':accurest-gradle-plugin') { testCompile project(':accurest-testing-utils') } + configurations { + messagingLibs + accurestGradlePluginLibs + } + + dependencies { + messagingLibs project(':accurest-messaging-root:accurest-messaging-integration') + messagingLibs project(':accurest-messaging-root:accurest-messaging-core') + messagingLibs project(':accurest-testing-utils') + messagingLibs 'org.codehaus.groovy:groovy-all:2.4.5' + + accurestGradlePluginLibs project(':accurest-gradle-plugin') + } + test { exclude '**/*FunctionalSpec.*' + systemProperties = testSystemProperties } task funcTest(type: Test) { include '**/*FunctionalSpec.*' - + systemProperties = testSystemProperties reports.html { destination = file("${reporting.baseDir}/funcTests") } } - task createClasspathManifest { - def outputDir = file("$buildDir/$name") - - inputs.files sourceSets.main.runtimeClasspath - outputs.dir outputDir - - doLast { - outputDir.mkdirs() - file("$outputDir/plugin-classpath.txt").text = sourceSets.test.runtimeClasspath.join("\n") - // Switch to 'sourceSets.main' after 'test.dependsOn's are removed - } + task archiveMessagingLibsDependencies(type: Sync) { + from configurations.messagingLibs.resolvedConfiguration.resolvedArtifacts.collect { it.file } + into messagingLibsDir } - test.dependsOn(':accurest-core:install') - test.dependsOn(':accurest-messaging-root:accurest-messaging-core:install') - test.dependsOn(':accurest-messaging-root:accurest-messaging-integration:install') - - funcTest.dependsOn(':accurest-core:install') - funcTest.dependsOn(':accurest-messaging-root:accurest-messaging-core:install') - funcTest.dependsOn(':accurest-messaging-root:accurest-messaging-integration:install') - - // Add the classpath file to the test runtime classpath - dependencies { - testRuntime files(createClasspathManifest) + task archiveAccurestGradlePluginLibsDependencies(type: Sync) { + from configurations.accurestGradlePluginLibs.resolvedConfiguration.resolvedArtifacts.collect { it.file } + into accurestGradlePluginLibsDir } + // archive task needs to have jars ready + archiveMessagingLibsDependencies.dependsOn project(':accurest-messaging-root:accurest-messaging-integration').tasks.jar + archiveAccurestGradlePluginLibsDependencies.dependsOn project(':accurest-gradle-plugin').tasks.jar + + test.dependsOn archiveMessagingLibsDependencies, archiveAccurestGradlePluginLibsDependencies + funcTest.dependsOn archiveMessagingLibsDependencies, archiveAccurestGradlePluginLibsDependencies + uploadArchives.dependsOn { funcTest } } -task wrapper(type: Wrapper) { - gradleVersion = '2.12' -} - - // REMOVE AFTER https://issues.gradle.org/browse/GRADLE-3433 IS FIXED buildscript { repositories {