I have a multi-module maven project that I am attempting to build.
The project structure is, generally:
Parent project (pom)
Sub Module 1
Sub Module 1A
Sub Module 1B
Sub Module 2
Sub Module 3
Inside of the parent project POM, I have the net.revel.code.formatter plugin defined in my build section to format the JAVA code inside of all of the sub-projects.
One of the attributes that I have to define in the plugin is the location of the configuration file. The file is located in a resource directory inside of Sub Module 3
I have the location attribute specified as ${project.parent.basedir}/submodule3/src/main/resources/eclipse/formatter.xml
The problem that I am running into is that when Sub Module 1A (as an example) is building, it seems that the ${project.parent.basedir} is resolving to the parent directory for Sub Module 1A (which is Sub Module 1) instead of the root of the project (where the property is actually defined).
Could someone help me sort out how to resolve this?
Related
I want to write a unit test that validates all JSON files from all dependent modules,
My Maven project structure is as follow,
Parent A -
module 1 - /resources/a.json
module 2 - /resources/a.json
.
.
.
module test - which reads the a.json from all parallel modules and validates.
Also, Ideally, my test code should not update after the new module added to the parent. only I should add a new dependency (of the newly added module) in the test module.
Can it be possible with some JUnit or Maven feature or plugin?
Thanks in advance.
I'm working on a Spring multi-module project. One of the child modules has some files under /test/resources/certs/ and a property file under /test/resources/test-ssl.properties.
───resources
│ test-ssl.properties
├───certs
│ test-keystore.p12
test-ssl.properties has a property that points to /certs/test-keystore.p12file.
server.ssl.trust-store=/certs/test-keystore.p12
In child modules pom.xml I'm using Maven plugin test-jar and in parent pom I've added this module as a dependency.
With this structure integration test present in parent module is able to successfully read classpath:test-ssl.properties but it fails to resolve its property value.
Spring throws FileNotFoundException: \certs\test-keystore.p12. What change we can do to make Spring read a file present in test jar?
Also tried the following patterns,
server.ssl.trust-store=classpath:/certs/test-keystore.p12
server.ssl.trust-store=classpath:certs/test-keystore.p12
server.ssl.trust-store=classpath*:/certs/test-keystore.p12
Please note that this test property doesn't try to load any certificate. It is there because property placeholder can find some value for the property during build.
Issue is resolved by changing integration-test phase to process-test-resources.
Credit goes to the following answer of Pascal Thivent:
The content of the test output directory (target/test-classes) is on the class path, not src/test/resources. But resources under src/test/resources are copied to the test output directory by the resources:testResources goal (which is bound by default to the process-test-resources phase).
I have a project named A, and there is a spring-config.xml and a config.properties in A. Project A dependency project B, and project B also have a resource file spring-datasource.xml.I want to filter resource during package project A ,so I use maven-resource-filter.But it can only filter the resource file in Project A, doesn't work for project B. How can i filter project B's resource file during package project A?
You cannot (and should not) filter an already packaged dependency.
Filtering is enabled only during the build of the project.
More precisely, during the process-resources phase.
To achieve what you want, you have two ways :
moving spring-datasource.xml in the A project
OR
filtering spring-datasource.xml directly in the B project build.
I have a gradle project with several subprojects. I have defined several dependencies with version numbers in the root project but not all subprojects use all of these dependencies.
root
- build.gradle
- compile 'math:math:1.0.0'
- settings.gradle
- include 'messages'
- include 'message-handler'
\ messages
- build.gradle
- //no math
\ message-handler
- build.gradle
- compile 'math:math'
Will my artifact of the messages project contain a dependency on the math library?
In other words, if I make a separate project that depends on the messages artifact from a nexus repository, would my dependency tree show the math library for this new project?
Yes - your messages project artifact will contain a dependency on the math library.
According to Gradle Documentation:
For most multi-project builds, there is some configuration which is
common to all projects. In our sample, we will define this common
configuration in the root project, using a technique called
configuration injection. Here, the root project is like a container
and the subprojects method iterates over the elements of this
container - the projects in this instance - and injects the specified
configuration
In other words, every configuration which is included in the root project will hold for all the sub-projects.
I have an existing project, MainProject. I want to convert it to a multimodule project. In Eclipse I created a parent modul, which is just a pom modul and another modul, Modul_1.
Then I moved my MainProject in parent file directory. (Actually i did not want to move in parent folder. unfortunately to make it possible that Main_project finds the parent modul, i must do that)
Works fine..
It looks like:
-->ParentModule
------>Mainproject
------>Modul_1
Modul_1 is only needed in jenkins. It means the programmers should only care about MainProject.
How should I check in the project in SVN? With the same file structure or can i check in independently in SVN?
if the mainproject doesn't refer to ParentModule, you could layout it like this :
-->ParentModule
-->MainProject
-->Modul_1
in parentmodule's pom.xml :
<modules>
<module>../MainProject</module>
<module>../Modul_1</module>
</modules>
for jekins, there are 2 ways to configure job :
checkout parent folder and point pom's location to ParentModule/pom.xml
checkout 3 svn locations to each folder for 3 projects and point pom to ParentModule/pom.xml
for eclipse , you can checkout only MainProject.