child module not found in maven multi project execution - maven

I created two projects(PROJECT-1,PROJECT-2) in the directory and i would like to execute both the projects in one click for that i create another project(PROJECT-3) in the directory and present these two projects((PROJECT-1,PROJECT-2) as modules and define packaging as pom Here i am using modules concept.
<modules>
<module>D:/20-6-2014/PROJECT-1</module>
<module>D:/20-6-2014/PROJECT-2</module>
</module>
I define the PROJECT-3 as parent for both the projects,while i run the PROJECT-3 it gives an error.
Error is: Child module D:\20-6-2014\PROJECT-3\PROJECT-1 of
D:\20-6-2014\PROJECT-3\POM.XML does not exist.

your directory structure should be like as follows PROJECT-3 is your parent project for PROJECT-1 and PROJECT-2
|
|
----PROJECT-3
|
|
----pom.xml
|
|
----PROJECT-1
| |
| |
| ------pom.xml
----PROJECT-2
|
|
-------pom.xml
and PROJECT-3's pom.xml should have
<modules>
<module>PROJECT-1</module>
<module>PROJECT-2</module>
</module>

Related

When running mvn test -Dtest=.. File can't be found

I have a citrusframework test, which when run with
mvn verify
it is able to find a json template file which is required to run the test, but when run with
mvn test -Dtest=SampleXmlIT#saveGroupTrips
suddenly it throws me following error:
Caused by: java.io.FileNotFoundException: src/test/templates/json/api/config/saveGroupTrips.json (No such file or directory)
my folder structure is as follows:
citrus-scada
|-src
| |-main
| |-test
| |-java
| | |- com : *.java testclasses
| |
| |-resources
| | |-com : xml-files which describes the testcases and reference the files required
| |
| |-templates : referenced files
|-target
does the working directory change?
src/test/templates is no Maven Standard Directory so there must exist some configuration which adds it to the classpath for test.
Because your test is named SampleXmlIT (IT is the important part, see here why) the test is executed with maven-failsafe-plugin in phase integration-test when you execute mvn verify
Now you call mvn test -Dtest=SampleXmlIT#saveGroupTrips but now it is executed with maven-surefire-plugin.
If you want to execute tests isolated with maven-failsafe-plugin try:
mvn verify -Dit.test=SampleXmlIT#saveGroupTrips
See also here

Maven: how to make things different in a parent while all children behave otherwise?

I have a multi-module Maven project (one level deep only). I like not to have to repeat the same things in all child projects, but how can I still do it (avoir repeating) when the parent project itself needs a different setting ?
The example I’m facing is when trying to produce a common folder for all artifacts and dependencies (but I can imagine other equivalent situations):
<properties>
<__.build.folder>../last_build</__.build.folder>
</properties>
Of course, this will lead to a situation where I have two last_build folder, one common to all child projects, one in the upper level folder.
How can I avoid that without having to duplicate the same setting in every child pom.xml ?
Can I use profiles ?
I don’t know, I’m new to Maven.
Thanks
Edit :
In this example, last_build is a subfolder of the folder containing the parent pom.xml. The child projects are all in other subfolders, from which last_build has to be addressed as "../last_build" - but not in the parent pom.xml !
|
*--rootFolder
| |
| *--last_build // aggregation folder
| |
| *--subProject1
| | |
| | *--pom.xml (../last_build)
| |
| *--subProject2
| | |
| | *--pom.xml (../last_build)
| |
| *--subProject3
| | |
| | *--pom.xml (../last_build)
| |
| *--pom.xml (last_build) // different here for the parent project
I don't think you're proceeding down a very useful path and I think that you may be confused about a few things.
First, at the highest level, your root or parent pom, there should be no project, no code, no resources, and no artifact, so there should also be no output or need for an output directory. All you should have at the highest level is the parent pom and subdirectories containing modules.
The next problem is that you think you need a common build folder. I am hard pushed to imagine a rational scenario where that would be necessary. The artifacts one typically builds in maven are self-contained jars/wars -- one per module, and these are cached in the local repo whenever you build through the install lifecycle. They can be used in situ from there.

Cmake: add_subproject & add_subfolder

I currently want to add some self written classes ("mycode.cpp" and "mycode.hpp") to a big existing C++ project that is configured with Cmake. These classes are located in "myfolder" which is located in the "lib/pointrender" folder of the existing project (see dummy hierarchy below).
|- libs
| |- core
| | |- ...
| |- pointrender
| |- myfolder
| | |- mycode.cpp
| | |- mycode.hpp
| |- existingclasses.cpp
| |- existingclasses.hpp
| |- project.cmake
|- CMakeLists.txt
In the CMakesLists.txt the pointrender folder is declared as a subproject.
declare_subproject(libs/pointrender)
How do I best add my code to the existing cmake configuration? Do I add it as a subfolder in the project.cmake with a seperate CMakeLists.txt in myfolder? Or do I best add it as a subproject with a seperate project.cmake file? What's the difference?
This project.cmake is being include()d be some CMakeLists.txt and get's executed as part of it. Authors of project you are using rolled this out for some reason, so it's probably better to use their infrastructure to add custom code.
The usual way to do this is writing your own CMakeLists.txt and add_subdirectory()ing it from the upper level.
If you wish more details you should update your question with project.cmake contents.

Create a war containing only image

I'm trying to create a war that is to be deployed in an EAR and that should contain only images.
My war source organization is as follows :
+---src
| +---main
| | +---java
| | +---resources
| | | \---META-INF
| | | \---resources
| | | \---images
| | | placeholder_image.jpg
| | | placeholder_template.png
| | |
| | \---webapp
| | \---WEB-INF
| \---test
| +---java
| \---resources
and my war effective organization is
+---META-INF
\---WEB-INF
\---classes
\---META-INF
\---resources
\---images
placeholder_image.jpg
placeholder_template.png
The images I want to serve are in the src/main/resources/META-INF/resources/images folder.
I package this war using maven-war-plugin.
Under which url will those images be available on my local machine, provided my war is indicated as available under the http://localhost:8080/myapp/ path ?
None. Content from WEB-INF is not statically served, resources is for classpath resources. You need to put the images (folder) directly under webapp or add an servlet that serves the content.
This depends on whether you deploy the war in a Servlet-3-compatible container like Tomcat 7 or Jetty 8.
If so, your resources should be visible under http://localhost:8080/myapp/images/....
See also this post, where the only difference is that the resources are packaged in a jar. For jars, this feature makes more sense than for WEB-INF/classes, as, like the first answer points out, you should simply put your resources directly into src/main/webapp if they are located in the same Maven module.

Create a maven project module tree?

I'm looking for a quick way, for any given multi-module project, to show a quick overview of the project hierarchy including only the modules in the project, excluding external dependencies.
eg for a project
project root
+- A
+- B
+- C
+- D
+- E
+- F
+- G
+- H
I would like to see a quick, single screen view for A-H (like it is depicted here) that gives me a fast digestible view to get an idea of a project structure. Ideally it would be command line output, not a platform specific solution (I note there is a tool for VisualStudio).
mvn dependency:tree is great but too verbose for this case, I suppose I could grep and cut the output apart but feels like there should be an easier way (ie another plugin).
You can filter the dependency tree: http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
So, if your group ID was com.foo.bar, you could get the projects in that group ID with:
mvn dependency:tree -Dincludes=com.foo.bar
Assuming all of your project's modules are within that group, that would cover your use case.
You could try this module here: MavenStructurePlugin
I had the same problem as you did and found it quite useful.
The output is pretty much what you seem to want:
test
|
|__ a
|
|__ b
|
|
\__ c
|
|__ d
|
|__ e
|
|__ f

Resources