This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 253599 - [81cat] Invalid groovy compiler configuration added to pom.xml when first Groovy file added to project.
Summary: [81cat] Invalid groovy compiler configuration added to pom.xml when first Gro...
Status: CLOSED FIXED
Alias: None
Product: groovy
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.1
Hardware: PC Other
: P3 normal with 2 votes (vote)
Assignee: bruno.flavio
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-21 04:09 UTC by kosmonaffft
Modified: 2019-02-28 08:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Fix for this issue based on my example of working configuration. (20.77 KB, patch)
2015-12-03 18:14 UTC, kosmonaffft
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kosmonaffft 2015-07-21 04:09:35 UTC
Steps to reproduce:

1) Create maven java project.

pom.xml:

<?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:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>info.kosmonaffft</groupId>
    <artifactId>mavenproject1</artifactId>
    <version>0.0.0</version>
    <packaging>jar</packaging>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

2) Add new Groovy file to it.

Now this section is added to pom.xml:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.6.0-01</version>
                </dependency>
            </dependencies>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>groovy-eclipse-compiler</artifactId>
            <groupId>org.codehaus.groovy</groupId>
            <version>2.6.0-01</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

3) Try to build project. Error has been occured:

--- maven-compiler-plugin:2.3.2:compile (default-compile) @ mavenproject1 ---
Failure to transfer org.codehaus.groovy:groovy-eclipse-batch/maven-metadata.xml from http://repository.codehaus.org was cached in the local repository, resolution will not be reattempted until the update interval of codehaus.org has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.groovy:groovy-eclipse-batch/maven-metadata.xml from/to codehaus.org (http://repository.codehaus.org): Failed to transfer file: http://repository.codehaus.org/org/codehaus/groovy/groovy-eclipse-batch/maven-metadata.xml. Return code is: 410 , ReasonPhrase:Gone.
Downloading: http://repository.apache.org/snapshots/org/codehaus/groovy/groovy-eclipse-batch/maven-metadata.xml
               
Using Groovy-Eclipse compiler to compile both Java and Groovy files
Compiling 1 source file to C:\Projects\mavenproject1\target\classes
source level should be comprised in between '1.3' and '1.6' (or '5', '5.0', ..., '7' or '7.0'): 1.8
-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
Found 0 errors and 0 warnings.
1 error
-------------------------------------------------------------
Comment 1 kosmonaffft 2015-07-21 04:13:09 UTC
Example of working configuration:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <compilerId>groovy-eclipse-compiler</compilerId>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.9.2-01</version>
                </dependency>
                <!-- for 2.8.0-01 and later you must have an explicit dependency on groovy-eclipse-batch -->
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                    <version>2.4.3-01</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-compiler</artifactId>
            <version>2.9.2-01</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <artifactId>groovy-all</artifactId>
        <groupId>org.codehaus.groovy</groupId>
        <version>2.4.4</version>
    </dependency>
</dependencies>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Comment 2 hefest 2015-09-04 11:00:37 UTC
Confirming bug using NB 8.0.2. Saw the following block added by NB automatically:


		 <plugin>
		  <artifactId>maven-compiler-plugin</artifactId>
		  <version>2.3.2</version>
		  <dependencies>
		   <dependency>
		    <groupId>org.codehaus.groovy</groupId>
		    <artifactId>groovy-eclipse-compiler</artifactId>
		    <version>2.6.0-01</version>
		   </dependency>
		  </dependencies>
		  <configuration>
		   <compilerId>groovy-eclipse-compiler</compilerId>
		  </configuration>
		 </plugin>
		 <plugin>
		  <artifactId>groovy-eclipse-compiler</artifactId>
		  <groupId>org.codehaus.groovy</groupId>
		  <version>2.6.0-01</version>
		  <extensions>true</extensions>
		 </plugin>

Got the same error. Removed the above snippet, could compile and execute my unit test from the command line (mvn clean -Dtest="MyTest" test).
Comment 3 ijay 2015-11-30 13:03:25 UTC
I met the same issue in my project using JDK 8 with groovy (and Maven). After tried for several times, I found the min version required is maven-compiler-plugin 2.7.0-01. But NB's groovy-related features are all BROKEN under 2.7.0-01, including quick fix, code completion, auto build... That is, I have to import the groovy classes manually, type the methods/fields manually and build the whole project manually after any change made to the groovy script (or I will get a ClassNotFoundException in runtime).

NB is totally unusable for me for projects built on JDK 8 and groovy scripts unless this bug is fixed

Env: NB 8.1 (Build 201510222201), JDK 1.8.0_66, Mac 10.11.2 Beta
Comment 4 kosmonaffft 2015-12-03 18:14:10 UTC
Created attachment 157651 [details]
Fix for this issue based on my example of working configuration.
Comment 5 Jiri Kovalsky 2015-12-21 10:04:21 UTC
FYI, I have just approved Anton's OCA [1] so you can integrate Anton's patch to our codebase Bruno. Thanks Anton!

[1] http://www.oracle.com/technetwork/goto/oca
Comment 6 bruno.flavio 2015-12-22 23:47:02 UTC
Anton, I've confirmed that the original behaviour happens as described.
The patch contributed works as intended and fixes this issue, thank you!

As indicated by ijay it's currently required to manually rebuild the project when groovy classes are changed. Reported as #256367 - "Groovy/Maven: must build after every source modification".
Comment 7 Quality Engineering 2016-01-02 02:42:21 UTC
Integrated into 'main-silver', will be available in build *201601020002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/db29212ef651
User: Bruno Fl
Comment 8 bruno.flavio 2016-03-16 12:19:20 UTC
Hello Anton,

Because you've just closed the issue I'm changing the issue state to Verified, according to the NetBeans issue lifecycle [1]. Closing the issue will be done by a QE in the next release.

Let me know if you agree with this and this issue was indeed verified by you to be fixed.

-Bruno.

[1] http://wiki.netbeans.org/IssueLifeCycle
Comment 9 kosmonaffft 2016-03-16 12:21:50 UTC
(In reply to bruno.flavio from comment #8)
> Hello Anton,
> 
> Because you've just closed the issue I'm changing the issue state to
> Verified, according to the NetBeans issue lifecycle [1]. Closing the issue
> will be done by a QE in the next release.
> 
> Let me know if you agree with this and this issue was indeed verified by you
> to be fixed.
> 
> -Bruno.
> 
> [1] http://wiki.netbeans.org/IssueLifeCycle

Ok, I agree with you.