Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17004

Configure Eclipse test source sets in Gradle build

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 5.x Backlog
    • Component/s: [Build]
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Overview

      Since Eclipse Photon supports separation of test source sets in the classpath, we should configure that within the Gradle build.

      Workaround

      The following workaround has been proposed by howlger until Gradle and Buildship properly support the new feature in Eclipse.

      apply plugin: 'eclipse'
      eclipse.classpath.file.whenMerged {
      
      	// separate output folders required to set the 'test' attribute
      	entries.find { it.path == 'src/main/java' }.output = 'bin/main'
      	def testSrc = entries.find { it.path == 'src/test/java' }
      	testSrc.output = 'bin/test'
      	testSrc.entryAttributes['test'] = 'true'
      
      	// libraries visible for test sources only?
      	entries.forEach { entry ->
      		def entryIn = { it.find { file(entry.path).equals(it) } }
      		if (entry.kind == 'lib') {
      			entry.entryAttributes['test'] =
      				entryIn(configurations.testRuntimeClasspath) &&
      				!entryIn(configurations.runtimeClasspath)
      		}
      	}
      }
      

      Related Issues

      Deliverables

      • Configure test source sets in the Eclipse classpath.
      • Update wiki.

        Attachments

          Activity

            People

            Assignee:
            sbrannen Sam Brannen
            Reporter:
            sbrannen Sam Brannen
            Last updater:
            Spring Issuemaster
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              1 year, 26 weeks, 1 day ago