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 245703 - Maven build does not pickup dependencies specified in plugin section
Summary: Maven build does not pickup dependencies specified in plugin section
Status: REOPENED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-15 18:03 UTC by matthias42
Modified: 2016-07-09 20:13 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample projects showing the problem (5.42 KB, application/zip)
2014-07-15 18:03 UTC, matthias42
Details
screenshot of the problem (60.35 KB, image/png)
2014-07-15 18:04 UTC, matthias42
Details
plain java project (ant base) showing the problem (33.74 KB, application/zip)
2014-07-16 20:54 UTC, matthias42
Details
Standalone sample project (4.07 KB, application/x-zip)
2014-07-22 21:07 UTC, matthias42
Details

Note You need to log in before you can comment on or make changes to this bug.
Description matthias42 2014-07-15 18:03:22 UTC
Created attachment 148072 [details]
sample projects showing the problem

I have a project in which I create one maven project constitutes the persistence unit/classes and the main project depends on that.

I use the eclipselink metamodel generator in the persistence project to build the meta model. The metamodel classes are correctly included in the generated jar, the main project builds correctly, but netbeans reports the metamodel class as missing.

I'll attach a zip file with a sample project. x2 depends on x1 - the metamodel classes are generated from x1. The second attachment is a screenshot showing the problem - the error indicator in TEst.java (line 4) is wrong - the class is present and accessible.
Comment 1 matthias42 2014-07-15 18:04:15 UTC
Created attachment 148073 [details]
screenshot of the problem
Comment 2 Jiri Prox 2014-07-16 08:38:35 UTC
reproducible
Comment 3 Tomas Zezula 2014-07-16 08:41:10 UTC
mvn
Comment 4 matthias42 2014-07-16 20:54:35 UTC
Created attachment 148090 [details]
plain java project (ant base) showing the problem

I tried to track it down a bit more - and it get interesting/strange (at least for me). Maybe this helps:

I can reproduce this problem with a plain java project (ant based, see attachment). The problem is visible, if

a) the maven cluster is active (problem goes away after disable maven plugin)
b) the referenced library x1 is in the local maven repository: /home/matthias/.m2/repository/test/x1/1.0-SNAPSHOT/x1-1.0-SNAPSHOT.jar

If the same library is referenced in another location (for example in the lib folder of the sample project), the correct behaviour is restored (no error is indicated).

I reactived the maven cluster at this point....

When I change the localRepositoryPath (i had to restart netbeans):

<localRepository>.m3</localRepository>

I get another problematic configuration:

/home/matthias/.m3/test/x1/1.0-SNAPSHOT/x1-1.0-SNAPSHOT.jar

So something changes the classpath of libraries, that match the local maven repository location.
Comment 5 matthias42 2014-07-21 20:40:50 UTC
This is reproducible in core-main head as of today. For me this is a show stopper.
Comment 6 matthias42 2014-07-21 22:33:12 UTC
Some more testing:

1. Clear the netbeans cache directory 
2. Open _only_ the x2 project

You will see, that code completes correctly and no error is shown. Open x1 and the error indicator is back.

I'll take a guess what happens - when x1 was never opened, netbeans relies on the class data inside the references jar from the dependency. When x1 is opened, netbeans gets smart and thinks it knows better, than the compiled and replaces the classpath info with info generated from the sources.

This would be all good and dandy, but I think the problem is, that the generated sources are not added to the classpath info that is generated.
Comment 7 matthias42 2014-07-22 21:07:31 UTC
Created attachment 148219 [details]
Standalone sample project

The problem is reproducible with one project alone - The attached project is compilable, as the missing class (Benutzer_.class/Benutzer_.java) is build at compile time (via the eclipselink annotation processor. Could it be, that the annotation processor is not picked up by netbeans and the generated sources dir is ignored?
Comment 8 matthias42 2014-07-22 21:26:06 UTC
This will be my final comment, as I found a workaround (but not a solution).

I defined the eclipselink model generator dependency in the plugin section, as the model generator is only needed to generate the model classes but not at runtime. When I move the model generator to the main dependency section it works. I declare it provided scope and can live with that (I already placed the JPA libraries there, but they are required by my code).

========== This works: ==========
<?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>test</groupId>
    <artifactId>x1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
            <version>2.5.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    <annotationProcessors>
                        <annotationProcessor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</annotationProcessor>
                    </annotationProcessors>
                    <compilerArgs>
                        <arg>-Aeclipselink.persistenceunits=local</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

========== This fails: ==========

<?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>test</groupId>
    <artifactId>x1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    <annotationProcessors>
                        <annotationProcessor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</annotationProcessor>
                    </annotationProcessors>
                    <compilerArgs>
                        <arg>-Aeclipselink.persistenceunits=local</arg>
                    </compilerArgs>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.persistence</groupId>
                        <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
                        <version>2.5.1</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>
Comment 9 Martin Balin 2016-07-07 08:38:10 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 10 matthias42 2016-07-09 20:13:44 UTC
Sorry - this is still reproducible with netbeans core-main as of 2016-07-09.