1

How would I access the actual fully qualified path so that I can write a file to it in the groovy script?

the properties

<properties>
    <gen.resources.config>target/generated-resources/config</gen.resources.config>
</properties>

the GMavenPlus plugin


  <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <id>groooovy</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <scripts>
                    <script><![CDATA[
  def filePath = "${gen.resources.config}/hello.json"

  println(filePath)

  new File(filePath).write(output)

                    ]]></script>
                </scripts>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <!-- any version of Groovy \>= 1.5.0 should work here -->
                    <version>2.4.7</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
        </plugin>
aristotll
  • 8,694
  • 6
  • 33
  • 53
ycomp
  • 8,316
  • 19
  • 57
  • 95

1 Answers1

1

Try the following code:

<scripts>
    <script><![CDATA[
        def output="test"
        def filePath = "${project.basedir}/${project.properties.getProperty('gen.resources.config')}/hello.json"

        println(filePath)

        new File(filePath).write(output)
        ]]></script>
</scripts>
aristotll
  • 8,694
  • 6
  • 33
  • 53