setting up maven environment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

setting up maven environment

Martin Mucha
Hi,

can anyone help how to setup maven project, which build groovy scripts?

I have working maven project, which builds java sources. I would like to build groovy scripts as well, into class files.

Internet is filled with not-working solutions, I cannot see any mention in documentation anywhere. Can anyone advise?

Martin.
Reply | Threaded
Open this post in threaded view
|

Re: setting up maven environment

Daniel Sun
Reply | Threaded
Open this post in threaded view
|

Re: setting up maven environment

Guillaume Laforge
Administrator
And a link to GMavenPlus:

Guillaume





--
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Reply | Threaded
Open this post in threaded view
|

Re: setting up maven environment

Martin Mucha
In reply to this post by Daniel Sun
Thanks for link,

sadly this seems to be one the links on web, which does not work/contain complete information. Build fails with: An Ant BuildException has occured: taskdef class org.codehaus.groovy.ant.Groovyc cannot be found

Ok nevermind, let me restate the question. I got furthest with following pom.xml below. The problem is, that when I build single groovy class:

package cz.???.processors.fdp


class ImpossibleToCompile {
}

I'm getting error:

1. ERROR in /home/mmucha/projects/FDP/fdp-nifi-processors/nifi-fdp-processors/src/main/groovy/cz/???/processors/fdp/ImpossibleToCompile.groovy (at line 1)
[ERROR] package cz.???.processors.fdp
[ERROR] ^
[ERROR] The type groovy.lang.GroovyObject cannot be resolved. It is indirectly referenced from required .class files


What can be wrong here? Or what maven configuration could I use to compile this triviality without any error?


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements. See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <version.groovy.all>2.4.3</version.groovy.all>
        <version.groovy-eclipse-batch>${version.groovy.all}-01</version.groovy-eclipse-batch>
        <plugin.version.groovy-eclipse-compiler>2.9.2-01</plugin.version.groovy-eclipse-compiler>
    </properties>

    <parent>
        <groupId>???</groupId>
        <artifactId>???</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>???</artifactId>
    <packaging>jar</packaging>

    <dependencies>

        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>${version.groovy.all}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-utils</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-standard-processors</artifactId>
            <version>${nifi.version}</version>
            <!--<scope>provided</scope>-->
        </dependency>

        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-record-serialization-service-api</artifactId>
            <!--<version>${nifi.version}</version>-->
            <!--<scope>provided</scope>-->
        </dependency>

        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-schema-registry-service-api</artifactId>
            <!--<version>${nifi.version}</version>-->
            <!--<scope>provided</scope>-->
        </dependency>

        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-record</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-mock</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <pluginRepositories>
        <pluginRepository>
            <id>bintray</id>
            <name>Groovy Bintray</name>
            <url>https://dl.bintray.com/groovy/maven</url>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
        
    </pluginRepositories>

    <build>
        
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version><!-- 3.1 is the minimum -->
                <configuration>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                    <!--<compilerArguments>-->
                        <!--<indy/>&lt;!&ndash; optional; supported by batch 2.4.12-04+ &ndash;&gt;-->
                        <!--<configScript>config.groovy</configScript>&lt;!&ndash; optional; supported by batch 2.4.13-02+ &ndash;&gt;-->
                    <!--</compilerArguments>-->
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-compiler</artifactId>
                        <version>${plugin.version.groovy-eclipse-compiler}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-batch</artifactId>
                        <version>${version.groovy-eclipse-batch}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>


        

    </build>
</project>

Reply | Threaded
Open this post in threaded view
|

Re: setting up maven environment

Martin Mucha
In reply to this post by Guillaume Laforge
Thanks for link!

But ... I'm sorry, my module have java and groovy files in it, and as documentation explains, this compiler has issues to build such modules... And, I'm not trying to be sarcastic/whatever here, if other modules, which don't have issues with that, are surprisingly hard to configure to be actually working, I as a groovy beginner should probably lead with something simpler. Can you look at my previous reply, if you can see anything wrong with my pom.xml?

thanks!

2018-01-11 15:45 GMT+01:00 Guillaume Laforge <[hidden email]>:
And a link to GMavenPlus:

Guillaume

--
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform