Hi all,

just discovered the jruby-maven-plugin and it does exactly what I need --
simply executing a small ruby script :)

Even though it is not the recommended approach, I have used the 'jruby:run'
goal to invoke the script because of it's simplicity.
However, I was not able to pass any commandline arguments to the scripts
ARGV variable. Is that possible at all using the ruby:run approach?

Ideally I wanted to call something like 'mvn jruby:run -Darg1=val1' and then
pass the java system property as a commandline arg to the ruby script, but
it did not work this way :(

Any suggestions are welcome.

Thanks and regards,
Torben


pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project>

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foo.utils</groupId>
    <artifactId>foo-utils-codegen</artifactId>
    <name>foo - utils - codegen</name>
    <version>1.0.0</version>

    <description>foo - utils - codegen</description>

    <dependencies>
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jruby-maven-plugin</artifactId>
            <version>1.0-beta-4</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <!-- BUILD -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jruby-maven-plugin</artifactId>
                <version>1.0-beta-4</version>
                <configuration>

                    <!-- this doesn't work :( -->
                    <!-- script>
                        ${basedir}/src/main/ruby/main_app.rb ${java.arg1}
                    </script -->

                    <script>
                        ${basedir}/src/main/ruby/main_app.rb
                    </script>
                    <!-- using libraryPath instead of currentDirectory
because otherwise
                        target folder would be created src/main/ruby -->
                    <libraryPaths>
                        <libraryPath>${basedir}/src/main/ruby</libraryPath>
                    </libraryPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Reply via email to