Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Test source folders (Gradle specific?)
Test source folders (Gradle specific?) [message #1404769] Tue, 05 August 2014 15:24 Go to next message
Michael Haefele is currently offline Michael HaefeleFriend
Messages: 3
Registered: August 2014
Junior Member
Hello,

I'm using Eclipse Kepler Service Release 2
Build id: 20140224-0627

I have a Gradle project using the Gradle IDE plugin with standard Gradle/Maven source folders (src/main/..., src/test/...).

The issue I'm having is when running applications or deploying to tomcat using src/main sources, the src/test sources are being included as well (which royally messes up my Spring config).

In IDEA I would make the folders as test sources, but I'm not seeing an equivalent option in Eclipse.

I'm honestly not sure if this is a Gradle plugin issue or a general Eclipse project setup issue.

A lot of the configuration stuff seem to be read-only (for example, the classpath and Source tabs in Run Configurations)

I guess I have a couple questions to start figuring this out:

1. What is the standard Eclipse project setup for working with maven style test folders? Is it a combination of classpath stuff and run/debug configuration tweaks? Do I have to do something to every run/debug configuration I use to indicate whether it's test or not?

2. It seems like there are two ways to do Gradle integration with Eclipse.
Either
a. use the Gradle eclipse plugin to generate .classpath/.project files and regenerate those whenever something changes
or
b. use the Eclipse Gradle plugin to integrate.
I...think... I should be using one or the other, but not both of those?
Is one preferred over the other?
Is there a step by step for importing an existing Gradle project into Eclipse somewhere?

3. I'm not insane, right? This seems like a lot of work for something I thought would be "out of the box" functionality.
Maybe it's supposed to work out of the box, but my configs have gotten mangled somehow?

Thank you very much.

PS. I really did spend about a day searching on this before posting. Apologizes if somehow I missed the one doc that would explain all of this.
Re: Test source folders (Gradle specific?) [message #1404807 is a reply to message #1404769] Tue, 05 August 2014 21:51 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
In JDT each project has exactly one classpath. You can, however, configure different output folders for class files per source folder. On the Java Build Path page this is enabled by "[x] Allow output folders for source folders".

How this is picked up by other tools I cannot say. For deployment into an application server this might actually suffice: deploy only target/classes but not target/test-classes.

How the Gradle plugin handles this I cannot tell. Best to ask them.

HTH,
Stephan

PS: The broader discussion about marking test sources has a long history: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=224708 with links to other bugs.
Re: Test source folders (Gradle specific?) [message #1405058 is a reply to message #1404807] Wed, 06 August 2014 13:16 Go to previous messageGo to next message
Michael Haefele is currently offline Michael HaefeleFriend
Messages: 3
Registered: August 2014
Junior Member
Thanks for the reply.

Apologies if any of this sounds like a big whinge.
I do find this frustrating, but I'm mostly looking for the best practices for using Maven style projects in Eclipse so that I can lock this down and move on.

I'll see what I can do for deploying the app to Tomcat.
I have not had a lot of luck turning off source folders for running standalone java applications. This may be a lack of experience with Eclipse for me, but it seems like a lot of the build path stuff is read-only (i'm not seeing an option to just remove a source folder from a Run Config).

The more I read on this, the more it seems like the "proper" representation is to give test sources their own project (gradle/maven module != eclipse project).
But then I'd probably have to throw out the Gradle integration and sync Eclipse with Gradle manually.

What I keep coming back to is that this should be a problem for literally every project that uses the maven structure and has tests (although perhaps less noticeable on some projects than others).
Eclipse's representation of the module is technically incorrect (assuming the build tool is the authoritative source of project structure).
I'd assume that's a large number of projects, given the popularity of Maven.
That's why I originally thought I must be missing something.

I'm curious how other Eclipse users work with these projects.
Maybe it's just a matter of not changing the behavior of the app based on the existence of the test classes (for example not doing automatic scanning to pick up bean classes)?
Or not running the app in the IDE?
Or just abandoning the Maven structure and putting tests in another module?

Also, to be honest, I've only tried this with the Gradle plug-in so far.
Perhaps the Maven plug-in does some tricks under the hood to better sync the two representations.

Thanks again,
Mike
Re: Test source folders (Gradle specific?) [message #1405094 is a reply to message #1405058] Wed, 06 August 2014 15:17 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Michael Haefele wrote on Wed, 06 August 2014 15:16

Eclipse's representation of the module is technically incorrect (assuming the build tool is the authoritative source of project structure).


When Eclipse's representation of projects was designed, Maven didn't even exist, i.e., Eclipse was setting a standard in a green field. Hence it doesn't make sense to blame that design in hindsight of other tools that made different design decisions at a later point in time.

For the rest, maybe some maven or gradle users are listening in this forum and can give more advice, but each of these tools has its own channel, where chances should be better to get the state-of-the-art answer to your questions. Also consider asking in the WTP forum regarding tomcat deployment.

regards,
Stephan
Re: Test source folders (Gradle specific?) [message #1405117 is a reply to message #1405094] Wed, 06 August 2014 16:13 Go to previous message
Michael Haefele is currently offline Michael HaefeleFriend
Messages: 3
Registered: August 2014
Junior Member
Hmmm... So I think I have a little more clarity here.

I tried out a sample maven project and all the setup that is visible in eclipse looks the same (build path, run config, etc), but when you actually run a java application it does the right thing in regards to dependencies.

So...
1. Representing a project the way maven does (ie without maven) is currently not supported in Eclipse without a plugin (that's what the enhancement you linked to is requesting).
* Doesn't mean it can't be done, it's just done outside of the Eclipse project representation (step 2 below).
2. The current/proper way this is handled is the plugin for build tool X takes care of it under the hood. Which seems like a perfectly valid solution and seems to work for Maven.
* Which also answers why my particular issue isn't more widespread.

So, as you noted, I'll need to mosey on over to the Gradle folks.

Thanks for your help,
Mike
Previous Topic:Making accessibilty work with both keyboard and JAWS
Next Topic:providing a code formatter profile from plugin
Goto Forum:
  


Current Time: Wed Dec 11 06:40:56 GMT 2024

Powered by FUDForum. Page generated in 0.03277 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top