windows xp - Maven can't discover workspace projects, junit, other libraries -
so have started using maven (with eclipse, , local implementation of sonatype) not long ago, after getting through initial pain though working.... apparently not !
i have main project pom , child pom (i using 'flat' hierarchy, sub projects in same folder parent pom). seems working ok.
the sub project started , 'released' , tested before started using maven. went maven solve 'dependencies' problems... or rather make them more complicated in instance.
most of 'maven' stuff seems work fine, can't resolve dependencies of 'sub projects' have been released local ms/repository
each day start eclipse , have same problems, have 'unable resolve imports' on personal libraries, , use them (such log4j, ddlutils etc).
i thought whole point of maven able put in import declaration library, add 'groupid' , other stuff child pom (or parent pom). , have jars downloaded automagically when run mvn install against parent.
however each day find have re-insert build path libraries (internal , external) via eclipse workspace , point them location of libraries have downloaded maven can't seem find them anywhere.
specifically running junit test, can run them workspace (using run junit) , pass fine. if try run them mvn test message saying java.lang;noclassdeffounderror: org/junit/assert (and same within eclipse running mvn test or cli) error message in output of failed execute goal org.apache.maven.plugins:maven.surfire-plugin:2.10:test pom , jar in m2_repo, , can find when search in sonatype, why can't maven find part of own system, exists in repo.
but works fine when run via eclipse , point independently downloaded junit library.
i don't know info may require, , i'm missing in either m2e plugin, maven install or in sonatype.
please i'm begining loose hair! , may forced return ant/ivy solution (but don't want have learn 'yet tool' (in case ivy).
thanks in advance
david.
ps. i'm on windows xp platform
edit... can maven build , release jar , pom though thinks failing tests (which itn't i'm doing them manually, , pass fine).
if in 'effective pom' tab of parent pom, plugin stated above not in there. guess means maven config setting, add it, , why isn't automatic when run first set of maven tests?
edit 2....
i found on apache plugin comments page (http://maven.apache.org/plugins/maven-surefire-plugin/plugin-info.html), ran code on cli, mvn surefire:help -ddetail=true -dgoal=test lots of stuff downloaded, , tests run, fail within maven ? (remember pass when run eclipse using 'run junit test)... solution...
it sounds need make eclipse aware projects in question maven projects. may have poms set projects, m2e plugin work need have either created project maven project ('new' -> 'project...' -> 'maven' -> 'maven project...'), or converted maven project right clicking selecting 'configure' -> 'convert maven project'. know project has been recognised maven project because there little blue 'm' in top left of icon, shown in screenshot below:

the main thing note in above picture 'maven dependencies' library. set automatically m2e plugin. whenever add dependency pom project's build path configured automatically, although may need force right clicking project , selecting 'maven' -> 'update maven configuration'. important thing if working should never have update build path yourself. moveover, if update changes make overwritten next time run 'update maven configuration' command.
also worth noting picture 2 dependencies 'mavenprojecttest' , 'primes' have folder icons next them. means have been picked workspace projects. work project must have 'workspace resolution' enabled, , projects picked need configured m2e maven projects well.
you mention downloading external libraries. shouldn't need download libraries - adding right dependency declaration external library maven download configured remote repository (the first time anyway - afterwards able local repository). default, maven central repository. add external library project follow link, enter library in search box, click on version link version require, taken page there dependency xml declaration can copy , paste pom.
one more thing may should make sure source folders follow maven default directory structure. is, test packages should contained in source folder called 'src/test/java', , main project packages should go in 'src/main/java'. otherwise maven not know find source code. possible configure pom tell maven expect source code in different source folders, highly recommended follow standard maven directory structure.
since have child modules, suggestion simplify things creating new maven project scratch can have play around with. once comfortable try getting m2e work multi-module project.
i remember pain when first getting grips maven, it's great once understand it's doing , working. highly recommend reading through free online book maven: complete reference - helped me out lot when getting started maven.
Comments
Post a Comment