1

I am migrating a legacy Maven build with the GMaven plugin to GMavenPlus and running into the issue that I don't know how I can call external Groovy classes from a local source folder inside my Groovy script.

Here's my previous setup:

<execution>
    <id>process-static-content</id>
    <goals>
        <goal>execute</goal>
    </goals>
    <phase>process-resources</phase>
    <configuration>

        <scriptpath>
            <element>${pom.basedir}/src/main/some-local-path</element>
        </scriptpath>
        <source>
            // call class from scriptpath that needs access
            // to Maven internals
            new SomeClassFromTheAboveFolder(project, log).run();
        </source>
    </configuration>
</execution>

Changing the <source> to <scripts><script> is obvious, but as far as I can tell, a <script> block can only either contain local groovy code or a file path to a script, but neither helps me implement the above usage pattern.

Can anybody provide insight?

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
  • To help, I need to understand your use case. What do you need the scriptPath element for? The project classes are already on the classpath. – Keegan Aug 17 '16 at 01:24
  • @Keegan that's exactly what I don't want. I want to use the classes in the build process only, without making them part of the jar – Sean Patrick Floyd Aug 17 '16 at 04:41
  • By "on the classpath" I mean it's on GMavenPlus's classpath. If you're just wanting the Groovy script to be able to access project classes, that should work out of the box, no scriptPath needed. – Keegan Aug 17 '16 at 18:09
  • I think I get it now. Let me know if I'm off-track and I'll update my answer accordingly. – Keegan Aug 18 '16 at 01:16

1 Answers1

1

So, you're wanting to add additional Groovy sources to GMavenPlus's classpath because those access classes are not part of the Maven project at the point in the lifecycle where GMavenPlus is invoked (e.g. maybe integratation test classes that you need to access during the generate-test-sources phase).

You're correct, there is no mechanism to accomplish this currently (because I simply hadn't considered this scenario). But I'm happy to add it. I've opened #66 to add this functionality.

Keegan
  • 11,345
  • 1
  • 25
  • 38