Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to configure system properties dynamically for a Gradle test task?
    primarykey
    data
    text
    <p>Is it possible to configure system properties dynamically for a Gradle test task? I haven't found a way to make it work.</p> <p>I am working within my own Gradle plugin, <code>GwtPlugin</code>. The <code>apply()</code> method looks like this:</p> <pre><code>/** Apply the plugin. */ void apply(Project project) { project.plugins.apply(JavaPlugin) project.plugins.apply(WarPlugin) project.extensions.create("gwt", GwtPluginExtension, project) project.extensions.create("testSuite", TestSuitePluginExtension, project) project.convention.plugins.gwt = new GwtPluginConvention(project) applyGwt(project) applyTestSuite(project) } </code></pre> <p>In the <code>applyTestSuite()</code> method, I create a tasks for my test suites. The definition for the <code>integrationtest</code> task looks like this:</p> <pre><code>// Run integration tests, assumed to be found in a class suites/IntegrationTestSuite. project.task("integrationtest", type: org.gradle.api.tasks.testing.Test, dependsOn: project.tasks.buildApplication) { workingDir = { project.testSuite.getWorkingDir() == null ? project.projectDir : project.testSuite.getWorkingDir() } scanForTestClasses = false scanForTestClasses = false enableAssertions = false outputs.upToDateWhen { false } include "suites/IntegrationTestSuite.class" systemProperty "integration.test.server.wait", project.gwt.getServerWait() beforeSuite { descriptor -&gt; if (descriptor.className == "suites.IntegrationTestSuite") { project.convention.plugins.gwt.rebootDevmode() } } afterSuite { descriptor -&gt; if (descriptor.className == "suites.IntegrationTestSuite") { project.convention.plugins.gwt.killDevmode() } } } </code></pre> <p>I want to get configuration for the <code>integration.test.server.wait</code> system property from <code>project.gwt.getServerWait()</code>. I can't figure out how to make this work, and I'm beginning to think it's not possible.</p> <p>If I hardcode the system property, everything works as expected:</p> <pre><code>systemProperty "integration.test.server.wait", 10 </code></pre> <p>The problem seems to be that the system property is set when the task is defined, but my extension doesn't have any values at that point. I can't figure out how to work around this. </p> <p>For instance, I tried putting the <code>project.gwt.getServerWait()</code> call in a closure, but in that case the system property gets set to a string like: </p> <pre><code>com.me.gradle.GwtPlugin$_applyTestSuite_closure10_closure42@320de756 </code></pre> <p>I also tried moving the <code>systemProperty</code> line to a <code>doFirst</code> block. In that case, the <code>doFirst</code> block gets a sensible value from my extension (I can print it), but the assignment is apparently too late to influence the test runner.</p> <p>Is there any way for me to accomplish this? If not, is there another way to pass dynamic configuration to my test runner?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload