title: How do I set a maven project property with a groovy script run with gmavenplus?
body: <p>I have a pom file that uses a property that I'd like to set within an external groovy script. This groovy script needs some existing properties to determine what to set the new property is, but, when I set the property <code>bindPropertiesToSeparateVariables</code> to false (within the script execution), all the necessary properties are exposed to the groovy script, but I am unable to set  my new property (<code>project.properties.setProperty('myproperty', value)</code> complains about 'project' not existing, and <code>properties.setProperty('myproperty', value)</code> doesn't work). When I set <code>bindPropertiesToSeparateVariables</code> to true, not all the necessary properties are exposed to the groovy script (<code>project.properties</code> does not have all the properties), but I can set my new property using <code>project.properties.setProperty('myproperty', value)</code> and it is set successfully.</p>
  
  <p>I am a bit confused as to what exactly <code>bindPropertiesToSeparateVariables</code> does, because the description of the property is basically just restating what is already in the name of the property. I tried using <code>parent.properties</code> but that didn't work. Can I manually define the properties in the plugin's configuration (right above where the script is executed) and then access them with <code>project.properties</code>? If that worked, what if new properties are added that I didn't manually define like that? Does <code>session.properties</code> work?</p>
  
  <p>Here is part of my pom file where the script is executed. The last line is where I need to access my new property.</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;com.example.group&lt;/groupId&gt;
          &lt;artifactId&gt;example-parent-pom&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;relativePath&gt;../../..&lt;/relativePath&gt;
      &lt;/parent&gt;
  
      &lt;groupId&gt;com.example.group&lt;/groupId&gt;
      &lt;artifactId&gt;example.artifact.id&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
  
      &lt;properties&gt;
          &lt;someOtherProperty&gt;someValue&lt;/someOtherProperty&gt;
          &lt;anotherProperty&gt;anotherValue&lt;/anotherProperty&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;pluginManagement&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
                      &lt;configuration&gt;
                          &lt;outputDirectory&gt;${project.build.directory}/sql&lt;/outputDirectory&gt;
                      &lt;/configuration&gt;
                      &lt;executions&gt;
                          &lt;!-- copy the basescript groovy files so they are accessible on the classpath during script execution --&gt;
                          &lt;execution&gt;
                              &lt;id&gt;Copy basescripts&lt;/id&gt;
                              &lt;phase&gt;generate-sources&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;copy-resources&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;configuration&gt;
                                  &lt;outputDirectory&gt;${project.build.directory}/classes/&lt;/outputDirectory&gt;
                                  &lt;resources&gt;
                                      &lt;resource&gt;
                                          &lt;directory&gt;${basedir}/../../../config/build/scripts&lt;/directory&gt;
                                          &lt;includes&gt;
                                              &lt;include&gt;**/*.groovy&lt;/include&gt;
                                          &lt;/includes&gt;
                                      &lt;/resource&gt;
                                  &lt;/resources&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                          &lt;execution&gt;
                              &lt;id&gt;Copy some of the scripts we use&lt;/id&gt;
                              &lt;phase&gt;generate-sources&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;copy-resources&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;configuration&gt;
                                  &lt;outputDirectory&gt;${project.build.directory}/classes/&lt;/outputDirectory&gt;
                                  &lt;resources&gt;
                                      &lt;resource&gt;
                                          &lt;directory&gt;${basedir}/../scripts&lt;/directory&gt;
                                          &lt;includes&gt;
                                              &lt;include&gt;**/SomeScriptWeUse.groovy&lt;/include&gt;
                                              &lt;include&gt;**/SomeOtherScriptWeUse.groovy&lt;/include&gt;
                                          &lt;/includes&gt;
                                      &lt;/resource&gt;
                                  &lt;/resources&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/pluginManagement&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;generate-sources&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;resources&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.gmavenplus&lt;/groupId&gt;
                  &lt;artifactId&gt;gmavenplus-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;allowSystemExits&gt;true&lt;/allowSystemExits&gt;
                      &lt;skip&gt;someValue&lt;/skip&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;set-myProperty&lt;/id&gt;
                          &lt;phase&gt;generate-sources&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;execute&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;scripts&gt;
                                  &lt;script&gt;file:///${basedir}/../scripts/setMyProperty.groovy&lt;/script&gt;
                              &lt;/scripts&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;com.example.another.group.id&lt;/groupId&gt;
                  &lt;artifactId&gt;homemade-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;skip&gt;${someSkipProp}&lt;/skip&gt;
                      &lt;verbose&gt;true&lt;/verbose&gt;
                      &lt;forceRemove&gt;true&lt;/forceRemove&gt;
                      &lt;someVersionProp&gt;1&lt;/someVersionProp&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;Just another execution&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;some-goal&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;configuration&gt;
                              &lt;someProperty&gt;${myProperty}&lt;/someProperty&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
  </code></pre>
  
  <p>Any suggestions are welcome. Please let me know if more information is needed.</p>