6

I've worked a little with m2eclipse in Eclipse Indigo and now I'm trying to use Maven from command line without Eclipse and without m2eclipse plugin. The m2eclipse has abililty to resolve the artifacts from the workspace without installing them to repository and this feature allows me to run my build without problems in Eclipse , but in CMD I'm getting the errors of missing jars.

[WARNING] The POM for AAA_7.1.1:ConfigurationView:jar:0.0.1-SNAPSHOT is missing, no dependency information available [WARNING] The POM for AAA_7.1.1:Beans:jar:0.0.1-SNAPSHOT is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [ERROR] Failed to execute goal on project Client: Could not resolve dependencies for project AAA_7.1.1:Client:pom:0.0.1-SNAPSHOT:.......

Our goal is to keep the repo clean as much as possible , that's the reason why I'd like to keep it working in a such way. So my question is how to resolve the dependencies without installing them to repo and if it's possible at all?

natan bolik
  • 61
  • 1
  • 2
  • That is definitely not the conventional way to go when using Maven. Why do you want/need to keep your local repository clean? – SpaceTrucker Oct 22 '12 at 06:10
  • we have 97 projects in our workspace , lot of them are quite heavy so we try to keep things simple as much as possible , also we're gonna use the Jenkins to run the nightly build and tests so if we need to install the jars it will take more time , also the build scripts for development build and the production build will be different in this case since development build can use the m2eclipse resolution and the production build can not , it adds more mess.. – natan bolik Oct 22 '12 at 11:51
  • If you really want to purge your local repo after the build, you could maybe look at [dependency:purge-local-repository](http://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html), with `-DsnapshotsOnly=true` ? Another thread : [Wiping out Maven local repository on build machine](http://stackoverflow.com/a/1310829/1677594) – Guillaume Husta Oct 22 '12 at 12:21
  • Is this what you looking for: [Dependencies with the scope system](http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies)? – yorkw Oct 22 '12 at 21:48
  • no , not realy, this solution useful for existing jars , I don't want to build jars and install them at all – natan bolik Oct 23 '12 at 14:39

2 Answers2

1

IMO, the standard way to go with Maven is mvn clean install.
But if I understand well your problem, you want to keep your local repository as clean as possible ?
One way to do that would be to use multiple local repositories, but I don't think it's possible at the moment (Maven 3.0).

However you can use alternate local repo with -Dmaven.repo.local or alternate settings with mvn --settings (see answer).

See also :

Community
  • 1
  • 1
Guillaume Husta
  • 4,049
  • 33
  • 40
  • if I get it right you propose to use the additional repo to store the project jars , but in my case my goal is to make a build without jars installation , just the same way I can achive it using the m2eclipse in Eclipse but through the CMD – natan bolik Oct 22 '12 at 11:59
  • Currently, I don't think it's possible to do it through the CLI only. Or you will have to store a duplicate local repository just for this... – Guillaume Husta Oct 22 '12 at 12:15
1

Basically you want a maven build, where the reactor contains all your 97 modules. To do this:
Create a parent, which contains all those 97 modules as children (if you are already multi module, you just need to configure the already existing parents to be the children of this new parent). Than start your build at that new parent. The convention is normally to have the parent in the upper directory. But you may also use relative paths that contain .. for the module location specification. There is also no need to inherit from the new parent in the existing parents. So you do not need to change any of the existing poms.

SpaceTrucker
  • 13,377
  • 6
  • 60
  • 99
  • I though of this option , just wasn't sure it will work and how exactly to configure it , can you confirm if it solves the following problem : I have two projects where one depends on another , for example when SomeClass from project A called in SomeOtherClass in project B and as result B has dependency on A , in configuration you've proposed I can assign the A and B to be the children of some Parent project and if I get it right I can move the dependency on A from B to Parent , as result B should be able to see the A through the Parent dependencies , am I right with my assumption? – natan bolik Oct 22 '12 at 13:47
  • @natanbolik `A` and `B` must not be the child of the same parent, to do what you suggest. Else you would get some incest in your models I guess (lol). Moving such a dependency of `B` to a parent only makes sense (if at all), if all the children of the parent have that dependency. You should use parents, when their children are kind of the same modules, user interfaces for examples. You shouldn't use parents to introduce dependencies (except for example introducing junit as a dependency). – SpaceTrucker Oct 22 '12 at 14:05
  • Incest between models - liked this one )) I'll check your solution , thanks for help ) – natan bolik Oct 22 '12 at 14:59