Specifically one created from our source , I mention in case control of source matters, is this viable?

-- 
Charles Monteiro

On June 18, 2016 at 2:12:54 PM, Mr Andersson (mr.andersson.002@gmail.com) wrote:

I was able to get it to work, both as separate groovy and java directories and as one directory ( basically a groovy directory with mixed ).

It is interesting how complex this task was. It would appear as if the Groovy community should have figured this out by now.

I finally ( after 10 hours ) was able to get it to work, using only ANT. The question is why Gmaven, GMaven2 Eclipse maven, and what not is even mentioned when it is as simple as an ANT task.

In constract, pulling in Scala and Kotlin ( during the process which I gave up on Groovy ) took seconds.

Relying on the Eclipse compiler is not a good thing as it has a history of breaking and not being up to date with any other compiler that one might wish to use.

The solution ( note that I change some other things as well, like I don't use src/main/java but just src ):

<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <org.springframework.version>4.0.6.RELEASE</org.springframework.version>

    <skipTests>true</skipTests>
    <maven.test.skip>true</maven.test.skip>

    <myproject.src>${basedir}/src</myproject.src>
    <myproject.test>${basedir}/test</myproject.test>
    <myproject.srcOutput>${project.build.directory}/WEB-INF/classes</myproject.srcOutput>
    <myproject.testOutput>${project.build.directory}/WEB-INF/classes</myproject.testOutput>
</properties>

<sourceDirectory>${myproject.src}</sourceDirectory>
<testSourceDirectory>${myproject.src}</testSourceDirectory>

<!--
    This is an important part, especially in development mode, where we treat the compiled output the same as when served through a container, we place in a /WEB-INF/classes/ directory, \
    rather than the default /classes/ allowing us to have consistent resources lookup through out all environments
-->
<outputDirectory>${myproject.srcOutput}</outputDirectory>
<testOutputDirectory>${myproject.srcOutput}</testOutputDirectory

<plugin>
    <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.5.1</version>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>

        <!-- See: http://stackoverflow.com/questions/17944108/maven-compiler-plugin-always-detecting-a-set-of-sources-as-stale -->
        <useIncrementalCompilation>false</useIncrementalCompilation>
    </configuration>

    <executions>
        <execution>
            <id>default-compile</id>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <id>groovyc-compile</id>
            <phase>compile</phase>
            <configuration>
                <target>
                    <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
                        <classpath refid="maven.compile.classpath"/>
                    </taskdef>

                    <mkdir dir="${myproject.src}"/>
                    <mkdir dir="${myproject.srcOutput}"/>
                    <groovyc destdir="${myproject.srcOutput}" srcdir="${myproject.src}" listfiles="true">
                        <classpath refid="maven.compile.classpath"/>
                        <src>
                            <pathelement path="${myproject.src}" />
                        </src>
                         
                        <javac source="1.8" target="1.8" debug="on" encoding="UTF-8"/>
                    </groovyc>

                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>



On 06/18/2016 07:34 PM, Schalk W. Cronjé wrote:
I dob't know about Ant, but in Gradle it us eady to get joint-compilation of Groovy & Java if eerything is under the src/main/groovy folder.



Sent from my Samsung device


-------- Original message --------
From: Mr Andersson <mr.andersson.002@gmail.com>
Date: 18/06/2016 18:39 (GMT+01:00)
To: users@groovy.apache.org
Subject: Re: Integrating Groovy with a Java EE application and Maven

I have gotten a bit further in my research and came up with this sample project which uses ant to compile the groovy classes but I can't get them to compile together.

To be able to have cyclic dependencies between Java and Groovy files.

Here is a standalone isolated maven project that contains everything:

http://www.speedyshare.com/TbQyG/Isolated.zip

Pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schem
 a
Location="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>Isolated</groupId>
    <name>Isolated</name>
    <artifactId>Isolated</artifactId>
    <version>1.0</version>
    <url>http://maven.apache.org</url>

    <packaging>jar</packaging>
     
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <skipTests>true</skipTests>
        <maven.test.skip>true</maven.test.skip>
    </properties>
     
    <dependencies>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.6</version>  
        </dependency>
    </dependencies>
     
    <build>
     
        <plugins>
            <plugin>
                <inherited>true</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
             
            <!-- http://groovy-lang.org/groovyc.html#_ant_task -->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                 
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <configuration>
                            <tasks>
                                 
                                <mkdir dir="${basedir}/src/main/groovy"/>
                                 
                                <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
                                    <classpath refid="maven.compile.classpath"/>
                                </taskdef>
                                 
                                <mkdir dir="${project.build.directory}"/>
                                <groovyc destdir="${project.build.outputDirectory}"
                                         srcdir="${basedir}/src/main/groovy/" listfiles="true">
                                    <classpath refid="maven.compile.classpath"/>
                                </groovyc>
                                 
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                     
                </executions>
            </plugin>
        </plugins>
    </build>
</project>