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 262857 - Maven insists on creating src/main/java directory, despite skipMain=true for maven-compliler-plugin
Summary: Maven insists on creating src/main/java directory, despite skipMain=true for ...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
: 256638 (view as bug list)
Depends on: 250809
Blocks:
  Show dependency tree
 
Reported: 2016-07-18 15:51 UTC by chrisjr
Modified: 2016-07-25 11:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample Cucumber project (5.67 KB, application/octet-stream)
2016-07-19 14:47 UTC, chrisjr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chrisjr 2016-07-18 15:51:06 UTC
I have an acceptance testing project that uses Maven, Cucumber, Java, CDI and JUnit. (JAR packaging). Cucumber is executed by the maven-surefire-plugin via a unit test like the following:

@CucumberOptions(
    plugin = { "json:target/cucumber.json", "html:target/cucumber-report.html" },
    features = { "src/test/features" },
    tags = { "~@wip" }
)
@RunWith(Cucumber.class)
public class RunCukesTest {
}

I believe that this is fairly standard. The Cucumber step definitions also need a beans.xml file for their CDI beans, and this is located in src/test/resources/META-INF/. The project has no src/main/ directory at all, and so I have configured maven-compiler-plugin with:

<skipMain>true</skipMain>

The skipMain setting is not strictly necessary; Maven "does the right thing" without it.

This all worked fine in NetBeans 8.0 too. However, NetBeans 8.1 is repeatedly recreating the non-existent src/main/java/ directory! And this is a problem because as soon as src/main/java/ exists, NetBeans starts complaining that it can no longer find beans.xml either. I am guessing that this is because NetBeans starts searching for the beans.xml file in the wrong place.

Everything would be fine if only either I could convince NetBeans that src/main/java/ does NOT need to exist for this project, or NetBeans could could locate its beans.xml file regardless of whether src/main/java/ exists or not.

I have briefly considered pushing my test code into the src/main/ directory instead of src/test/, but that is not how maven-surefire-plugin expects to work either. I have also tried configuring my POM as follows:

<build>
    <sourceDirectory>${project.basedir}/src/test/java</sourceDirectory>
    ...
</build>

But this confuses NetBeans even more!
Comment 1 Tomas Stupka 2016-07-19 14:06:14 UTC
could you please attach a sample project 
thanks
Comment 2 chrisjr 2016-07-19 14:47:46 UTC
Created attachment 160550 [details]
Sample Cucumber project

This project is fine "out of the box". To reproduce the problem, try adding a new field of unknown type to the SampleStepsDefn class. This will cause NetBeans to create a src/main/java directory, which in turn will trigger warnings about "CDI artifact is found but there is no beans.xml file".
Comment 3 Tomas Stupka 2016-07-19 16:07:56 UTC
> To reproduce the problem, try adding a new field of unknown type to the SampleStepsDefn class. 
what exactly am i supposed to do - to create a new type like Reporter and then add it and clean/build? 
anything else?

thanks
Comment 4 chrisjr 2016-07-19 18:50:16 UTC
All you need to do is to open the project in NetBeans and then add a field to SampleStepsDefn such as

private Method method;

It doesn't have to be a Method field; any type that would require a new import statement would suffice. NetBeans should create the src/main/java directory as it tries to guess what the new import statement should be.
Comment 5 Tomas Stupka 2016-07-20 13:00:04 UTC
org.netbeans.modules.java.hints.errors.CreateElement.getPossibleSourceGroups() calls SourceGroupModifier.createSourceGroup() while merely trying to figure out to which SG a source belongs. 
this unfortunately forces maven to create the src/main/java directory in case it doesn't exist

reassigning for further evaluation
Comment 6 chrisjr 2016-07-20 13:18:09 UTC
Note that this issue is not present in NetBeans 8.0. I therefore consider this to be a regression.
Comment 7 Tomas Stupka 2016-07-20 14:53:37 UTC
*** Bug 256638 has been marked as a duplicate of this bug. ***
Comment 8 Svata Dedic 2016-07-25 11:29:02 UTC
Fixed in jet-main#feccaef2859a, behaviour introduced by patch supplied in issue #250809 -- I didn't thought about the 'creation' side effect, sorry.