Skip to content

Commit

Permalink
Add configuration cache support
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Aug 22, 2020
1 parent 1e5fa57 commit ffa8159
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
18 changes: 1 addition & 17 deletions src/main/groovy/nebula/plugin/info/InfoBrokerPlugin.groovy
Expand Up @@ -17,16 +17,12 @@
package nebula.plugin.info

import groovy.transform.Canonical
import org.gradle.BuildAdapter
import org.gradle.BuildResult
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import java.util.concurrent.atomic.AtomicBoolean

/**
* Broker between Collectors and Reporters. Collectors report to this plugin about manifest values,
* Reporters call this plugin to get values.
Expand All @@ -41,8 +37,8 @@ class InfoBrokerPlugin implements Plugin<Project> {
private List<ManifestEntry> manifestEntries
private Map<String, Collection<Closure>> watchers
private Map<String, Object> reportEntries
private AtomicBoolean buildFinished = new AtomicBoolean(false)
private Project project
private Map<String, String> test =[:]

void apply(Project project) {
this.manifestEntries = new ArrayList<ManifestEntry>()
Expand All @@ -51,14 +47,6 @@ class InfoBrokerPlugin implements Plugin<Project> {
this.project = project

InfoBrokerPluginExtension extension = project.getExtensions().create('infoBroker', InfoBrokerPluginExtension)

project.rootProject.gradle.addBuildListener(new BuildAdapter() {
@Override
void buildFinished(BuildResult buildResult) {
buildFinished.set(true)
}
})

project.afterEvaluate {
filterManifestEntries(extension)
}
Expand Down Expand Up @@ -147,10 +135,6 @@ class InfoBrokerPlugin implements Plugin<Project> {
throw new IllegalStateException('Build reports should only be used from the root project')
}

if (!buildFinished.get()) {
throw new IllegalStateException('Cannot retrieve build reports before the build has finished')
}

return Collections.unmodifiableMap(reportEntries)
}

Expand Down
13 changes: 0 additions & 13 deletions src/test/groovy/nebula/plugin/info/InfoBrokerPluginSpec.groovy
Expand Up @@ -102,19 +102,6 @@ class InfoBrokerPluginSpec extends ProjectSpec {
attrs3['MyKey'] == 'MyValue' // Still around
}

def 'it throws an exception when build reports are requested prior to build end'() {
given:
project.apply plugin: InfoBrokerPlugin

when:
def infoBrokerPlugin = project.plugins.getPlugin(InfoBrokerPlugin)
infoBrokerPlugin.addReport('test', 'some value')
def reports = infoBrokerPlugin.buildReports()

then:
thrown IllegalStateException
}

def 'can not add multiple values'() {
when:
InfoBrokerPlugin broker = project.plugins.apply(InfoBrokerPlugin)
Expand Down
@@ -0,0 +1,24 @@
package nebula.plugin.info

import nebula.test.IntegrationTestKitSpec

class InfoPluginConfigurationCacheSpec extends IntegrationTestKitSpec {

def 'plugin applies with configuration cache'() {
buildFile << """
plugins {
id 'nebula.info'
id 'java'
}
"""
writeHelloWorld('nebula.app')


when:
runTasks('--configuration-cache', 'compileJava', '-s')
def result = runTasks('--configuration-cache', 'compileJava', '-s')

then:
result.output.contains('Reusing configuration cache')
}
}
Expand Up @@ -62,7 +62,6 @@ class DependenciesInfoPluginSpec extends PluginProjectSpec {
configurations.compileClasspath.resolve()

when:
brokerPlugin.buildFinished.set(true)
def reports = brokerPlugin.buildReports()

then:
Expand Down

0 comments on commit ffa8159

Please sign in to comment.