Skip to main content

Maven configuration issues with Eclipse

20 replies [Last post]
kleopatra
Offline
Joined: 2003-06-11
Points: 0

Karl,

just noticed that the current revision doesn't compile locally. Yeah, I know that you want to leave all the heavy lifting to maven - but I hate it when I can't compile as usual. For daily work, I simply want to let Eclipse do its stuff, don't want to trigger maven for each and everything. So pleeeease add the missing test libs again.

Opinions?

Thanks
Jeanette

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kschaefe
Offline
Joined: 2006-06-08
Points: 0

Oh, don't give me that youngster stuff either. I was debugging code in the 80s.

Karl

kschaefe
Offline
Joined: 2006-06-08
Points: 0

You should have several projects for SwingX:
swingx
swingx-all
swingx-testsupport
swingx-painters
swingx-core

swingx will contain no source files. It is simply a container project. The other projects will contain source folders and should each have a Maven Dependencies section.

You should not have to manually muck with the project classpath or source folders; if you have done so, then you are on the wrong track.

If you are not seeing the subprojects, right-click in the Package Explorer and Import.... Click Existing Projects into Workspace. Since these are subprojects of an SCM managed project make sure that Copy projects into workspace is unclicked (I think it is by default). The projects may not come in with Maven or SVN on them. If so, do Maven -> Add Dependency Management and Team -> Share as appropriate.

The purpose of maintaing separate projects is to help Eclipse manage your classpath. This will ensure that cross-dependencies do not occur.

Karl

Karl

kleopatra
Offline
Joined: 2003-06-11
Points: 0

Karl,

looks like I'm too dumb for maven: still don't know how to get a clean checkout to start with :-(

Facts:
- have a complete "normal" project checkout from svn/swingx/trunk, that's manually configured with source folders, libs, etc. This is the-wrong-thing.
- the usual remedy is to start over with a clean checkout, doing-the-right-thing
- the obvious path is new-project/maven/checkout from SCM: copy/choose the swingx svn location at java.net into the combo and hit okay. Doesn't work because the scm type dropdown is empty which leads to a "no connector" error later
- next I tried the import/maven/existing maven project from the root of that complete "normal" project above. Result are several new projects swingx-something as listed in your post. The sources physically reside under the "normal" project, inverse to the outcome you mentioned.

Hmm ...

CU
Jeanette

kleopatra
Offline
Joined: 2003-06-11
Points: 0

a small step forward: turned out the install wasn't complete - needed to install the w2e-extras as well (unsane - connecting to version control shouldn't be regarded as "extra", dooh). Now the scm type dropdown in the checkout dialog is filled. After several trials managed to import swingx/trunk into a previously created project. Now have

[code]
// my previously created project
jlabs-myproject
// directory created by checkout, physically contains
all source files
maven.0394309u403u409409
// projects created by checkout, have sourcefolders which
are linked to the files above and auto-dependencies
swingx-project
swingx-all
swingx-painters
... etc
[/code]

Something still fishy: the individual projects are my future workarea, right? Can run tests and visuals manually (shift-alt-x-t/j) and can run the complete test-suite on swingx-project (right-click and run-as/maven test). That's fine. Cannot do the same on individual project, f.i. doing on swingx-painters gives the following console output

[code]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SwingX Painter Support 1.6.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] Missing POM for org.swinglabs:swingx-testsupport:jar:1.6.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.171s
[INFO] Finished at: Tue Oct 05 13:08:49 CEST 2010
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project swingx-painters: Missing:
----------
1) org.swinglabs:swingx-testsupport:jar:1.6.3-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=org.swinglabs
-DartifactId=swingx-testsupport -Dversion=1.6.3-SNAPSHOT
-Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.swinglabs
-DartifactId=swingx-testsupport -Dversion=1.6.3-SNAPSHOT
-Dpackaging=jar -Dfile=/path/to/file -Durl=[url]
-DrepositoryId=[id]

Path to dependency:
1) org.swinglabs:swingx-painters:pom:pom:1.6.3-SNAPSHOT
2) org.swinglabs:swingx-testsupport:jar:1.6.3-SNAPSHOT

----------
1 required artifact is missing.

for artifact:
org.swinglabs:swingx-painters:pom:1.6.3-SNAPSHOT

from the specified remote repositories:
swinglabs-snapshots (http://oss.sonatype.org/content/repositories/swinglabs-snapshots/,
releases=false, snapshots=true),
swinglabs-releases (http://oss.sonatype.org/content/repositories/swinglabs-releases/,
releases=true, snapshots=false),
sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots,
releases=false, snapshots=true),
central (http://repo1.maven.org/maven2,
releases=true, snapshots=false)
-> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and
possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MultipleArtifactsNotFou...

[/code]

no idea what's happening (and don't want to care ;-) - but feels insane again: why does it look into the "outside" repository? Would expect it to use the locally available projects ...

other quirks:
- how to customize the (auto-created) project names? Just assume checking out another branch (if we had one) or an older release will try to create projects with the same names (and fail)
- on a previous checkout forgot to specify the "trunk", the checkout failed completely with a weird message from svn

[code]
Obstructed update
svn: Failed to add directory 'D:\Daten\eclipse_workspace
\workspace\jlabs-swingx-maven-top\maven.1286272952976
\branches\binding\src\java\org\jdesktop\swingx\expression
\.svn': object of the same name as the administrative directory
[/code]

all in all - it's a very unpleasant experience. Currently feels like more effort than it's worth. Actually, don't quite understand why you youngsters (duck ) are so keen on working with such incomplete/buggy tools which give me the creepy feel of way back 80ies ... debug on the command line, yikes, certainly not me.

Not sure if I want to continue down this path, after all the "normal" all-in-one project works fine (after manually adding source folders and the recent junit and mockito).

CU
Jeanette

kschaefe
Offline
Joined: 2006-06-08
Points: 0

From the build environment, you need to run tests from the right-click -> Run As -> JUnit Test. It looks like you used right-click -> Maven -> ???.

The modules contain dependencies, but have no way of finding one another without using the parent POM (the one in the base SwingX directory) to place them in a common reactor. If you don't use the parent, you can do what you want by installing the testsupport code into your local repository. However, from within Eclipse, once the projects are properly configured, you do not need to do a thing with the Maven right-click options unless you want to modify the POM file(s).

I don't think it's possible to reconfigure the project names; my work solution was to use a secondary workspace. I found that I rarely needed to run the branch but merge with it, so my branched copy is not Mavenized.

Strange message. I wonder if an .svn directory got "checked in" somerhow or attempted to.

There's nothing command-line here. At least when I use it, unless I need to debug POMs, which is rare. Everything from a development perspective should be the same as before. You are, of course, able to buck the plugin and manage your resources manually...if you want.

Karl

kleopatra
Offline
Joined: 2003-06-11
Points: 0

> From the build environment, you need to run tests
> from the right-click -> Run As -> JUnit Test. It
> looks like you used right-click -> Maven -> ???.
>

The run-as submenu increased by about 10 entries or so (like maven build, maven package ...). I do right-click -> Run as -> Maven test to run all tests in the project assuming that's the equivalent to the old test task in the ant build.

> The modules contain dependencies, but have no way of
> finding one another without using the parent POM (the
> one in the base SwingX directory) to place them in a
> common reactor. If you don't use the parent, you can
> do what you want by installing the testsupport code
> into your local repository. However, from within
> Eclipse, once the projects are properly configured,
> you do not need to do a thing with the Maven
> right-click options unless you want to modify the POM
> file(s).
>

hmm ... but I want to run the complete tests per-project, that is per-painters, per-core ... Obviously wouldn't dare to touch the poms ;-)

> I don't think it's possible to reconfigure the
> project names; my work solution was to use a
> secondary workspace. I found that I rarely needed to
> run the branch but merge with it, so my branched copy
> is not Mavenized.
>

hmm ...

> Strange message. I wonder if an .svn directory got
> "checked in" somerhow or attempted to.
>

no idea

> There's nothing command-line here.

was referring to the error message cited above, "re-run Maven with the -e switch" which looks like implying the command line - could be wrong, of course.

Just to be sure: the project structure as outlined in my previous post is what to expect after "import from SCM", pointed to the svn trunk at java.net? Feels a bit strange to have the jlabs-myproject as a pure source container and the swingx-whatever pointing to that.

CU
Jeanette

kschaefe
Offline
Joined: 2006-06-08
Points: 0

> > The modules contain dependencies, but have no way
> of
> > finding one another without using the parent POM
> (the
> > one in the base SwingX directory) to place them in
> a
> > common reactor. If you don't use the parent, you
> can
> > do what you want by installing the testsupport
> code
> > into your local repository. However, from within
> > Eclipse, once the projects are properly
> configured,
> > you do not need to do a thing with the Maven
> > right-click options unless you want to modify the
> POM
> > file(s).
> >
>
> hmm ... but I want to run the complete tests
> per-project, that is per-painters, per-core ...
> Obviously wouldn't dare to touch the poms ;-)

You can run all the unit tests in a module with right-clicking on the tests folder. No need to invoke Maven for that. I never had the Ant build working in my Eclipse, I just used the IDE to facilitate that. If you want to run all unit tests across all modules, then you would need to run Maven tests on the SwingX POM.

> > There's nothing command-line here.
>
> was referring to the error message cited above,
> "re-run Maven with the -e switch" which looks like
> implying the command line - could be wrong, of
> course.

It is, but you're doing the wrong thing in the first place. Use the IDE to do IDE tasks and Maven to do build tasks. The IDE is using Maven to configure pieces, but you should still do it the IDE way.

> Just to be sure: the project structure as outlined in
> my previous post is what to expect after "import from
> SCM", pointed to the svn trunk at java.net? Feels a
> bit strange to have the jlabs-myproject as a pure
> source container and the swingx-whatever pointing to
> that.

They are subdirectories, which is how Maven handles things. Our parent POM is both a parent and an aggregator. Being an aggregator it knows about all modules it aggregates. The aggregrator does not need to be a parent POM, but a lot of times it is. We could have a separate module that does aggregation for all the pieces and simply use the parent POM to be a place to define commonalities between the modules. We have no reason to change the parent, however, and I am reticent to add more packaging than required at this time.

Karl

kleopatra
Offline
Joined: 2003-06-11
Points: 0

> >
> > hmm ... but I want to run the complete tests
> > per-project, that is per-painters, per-core ...
> > Obviously wouldn't dare to touch the poms ;-)
>
> You can run all the unit tests in a module with
> right-clicking on the tests folder.

you _know_ that's not the same - so why say it ;-) That's running all tests, the xxIssues as well (which are expected to fail).

> No need to
> invoke Maven for that. I never had the Ant build
> working in my Eclipse, I just used the IDE to
> facilitate that. If you want to run all unit tests
> across all modules, then you would need to run Maven
> tests on the SwingX POM.
>

haha - can't be that silly me achieved something (running the ant test task ) you didn't And as I said: running all tests across all subprojects _does_ work by right-click on swingx-project -> Run As -> maven test. What's not working is trying the same on a subproject. Which should work, IMO.

> > > There's nothing command-line here.

> It is, but you're doing the wrong thing in the first
> place. Use the IDE to do IDE tasks and Maven to do
> build tasks. The IDE is using Maven to configure
> pieces, but you should still do it the IDE way.
>

good advice, but then: how exactly do I run the tests (that is, those we expect to pass) on a subproject only?

Thanks
Jeanette

kleopatra
Offline
Joined: 2003-06-11
Points: 0

Karl,

I'm stuck - the screenshot of the checkout dialog (fig. 3.3) in the m2eclipse book looks like I would expect it to look:

http://www.sonatype.com/books/m2eclipse-book/reference/eclipse-sect-crea...

in my environment, the dropdown for the scm type is always empty. Ideas why that would happen?

Thanks
Jeanette

kschaefe
Offline
Joined: 2006-06-08
Points: 0

Mine is too. So, I scrapped that idea to try to troubleshoot you through adding it post project creation. See my other message.

Karl

tbee
Offline
Joined: 2003-07-23
Points: 0

When introducing Maven in our company I discovered that m2eclipse works well for everything "main", but stuff in the "test" folders have problems. Main issue is that often test resources are not found at runtime, and it gets even worse when you are doing server side development with embedded WAR containers. There are some workarounds in Eclipse, but they only go so far.
I had a discussion with the m2eclipse developers, but it appears they value Maven compatibility more than ease of development in Eclipse. The main issue is that if you make test stuff available in Eclipse, it gets treated equal to the stuff in main; Eclipse does not separate between main and test. It may then run correctly in Eclipse, but you may not be able to build it using Maven command line, because command line does separate main and test. Personally I find development more important than Maven compatibility within the context of Eclipse, but they were not swayed.

So I decided to allow a second approach by downloading the dependency jars into a "_lib" folder that is ignored by the SCM and simply create a regular Eclipse project. This works fine, and as long as you're not too heavy into cross component development even great. The trade off is that it requires more "install" and "lib" command line calls to update stuff.

kschaefe
Offline
Joined: 2006-06-08
Points: 0

Jeanette,

Huh? I'm confused, using the m2eclipse plugin there is never a need to manually run the mvn command. It does all the work for you.

Let me guess: you never installed it. ;)

Karl

kleopatra
Offline
Joined: 2003-06-11
Points: 0

Karl,

well it is installed, but judging from your surprise, maybe not completely ... cough ..?

I can build, test, explicitly via right clicking the project, menu item run-as and then choose the maven task (?) like "maven build", ... etc. That's fine and working. But how do I tell eclipse to use maven for compiling (in the background?). Missing something, certainly ... ;-)

CU
Jeanette

kschaefe
Offline
Joined: 2006-06-08
Points: 0

Jeanette,

That should happen automatically. The project folder should have a little "M" in the upper left-hand corner to signify that the project is Maven-controlled. If it does not, right-click on the project, select Maven, and click Enable Dependency Management.

Karl

kleopatra
Offline
Joined: 2003-06-11
Points: 0

hmm ... doesn't work - still no icon plus then running individual tests/visuals by shift-alt-x-t doesn't work at all ("no class XXTest found*). But thanks for the pointer, will try a clean checkout, maybe that'll help.

CU
Jeanette

kschaefe
Offline
Joined: 2006-06-08
Points: 0

The best thing to do may be to open a new project and do "Maven/Checkout Maven Projects from SCM". It will create a new Mavenized from the start project. May be the best way to fix the issue if the configuration is hosed.

Karl

kleopatra
Offline
Joined: 2003-06-11
Points: 0

Hmm .. is there any documentation about what exactly to do? SCM is what? Connect to SVN before doing the maven/create... ? dooohhh ... how I hate tool switching especially when the help button leads into nowhere.

Sorry, in the mood to hyperventilate
Jeanette

kschaefe
Offline
Joined: 2006-06-08
Points: 0

Yeah, that SCM thing sucks. Damn, should have fixed all problems, but instead is causing more.

Did you get the little M in the corner when you tried to add the Maven to the project? If so, right-click the project and do "Maven -> Update Project Configuration". If not, let me know.

Karl

kleopatra
Offline
Joined: 2003-06-11
Points: 0

yeah, have the little m now - clicking the update project config does nothing visibly. Still can't run the tests (or anything else) manually. hmm ..

Jeanette

kleopatra
Offline
Joined: 2003-06-11
Points: 0

have to run now - will dig further one of these days. For now, I disabled the maven project management and added the libs manually. Far from optimal, but at least can run the tests and visuals again.

Thanks for your help so far
Jeanette