Reputation: 5865
This is how the project may looks like:
moduleA
-- pom.xml
moduleB
-- pom.xml
moduleA has a dependency on moduleB. I have set <modules>
in the parent pom.xml and other configurations in the child pom.xmls. And I can run mvn package
in the parent dir, but every time I run mvn package
in the directory of moduleA it fails.
I know that running mvn package -pl moduleA
in the parent directory can fix the problem. Since Apache Flume allows me to compile any single module in its own directory, why can't my project?
Upvotes: 0
Views: 6759
Reputation: 17915
I had this issue: maven session does not declare a top level project
when I'm trying to run one module through command line like :- mvn clean install -pl moduleA
where it was looking for parent module, So I've tried this & it worked with :- mvn clean install -pl .,moduleA
in your case you can try this assuming dependency is already build & available in maven repo, else mvn clean install -pl .,moduleA --also-make
should work. This will build only one specific project in multi-module maven project & as we've specified "." it would build parent pom which resolved the issue.
Upvotes: 1
Reputation: 675
Instead of launching goal "package", launch goal "install" on the root pom (or just moduleB). This will place moduleB in the local repository (~/.m2/repository) and Maven will be able to fetch it when it compiles only moduleA. Then you'll be able to compile only moduleA.
Upvotes: 1