I have two mavenized projects
Project_A: Java Project
Project_B: Java Web Project
Earlier, before mavenizing both projects, i had refrence(buildpath) of Project_A in Project_B.
Now i have configured both projects with maven2. MY questions is, how can i add a refrence of Project_A in Project_B that WAR of Project_B can be runnable
so far i have tried following chunk of code which seems to work but on runtime Project_B's WAR throw an exception in applicationContext that an Instance of Project_A's class cannot be initiated.
1- Project_A is cleaned and installed in local repository with name "myproject-1.0.jar"
where build snippet(Project_A's POM) is as follows#
Edited Part
<modelVersion>4.0.0</modelVersion>
<groupId>org.myurl<groupId>
<artifactId>projectA</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>${project.artifactId}-${project.version}</name>
build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
</configuration>
</plugin>
</plugins>
</build>
Snippet of Project_B's POM, where i am adding installed jar of Project_A
<dependency>
<groupId>org.myurl</groupId>
<artifactId>projectA</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
Thanks for suggestions in advance.
Answer :
Actually there was not any problem with maven. Above configurations in POM are absolutely correct. I had moved properties files under /Resources and later i have forgotten to change paths in those classed where properties files are utilized.
Nevertheless i am thankful to Dolphin and Nicola Musatti for their suggestions.
You are on good way, pom snippet is fine what you need to do now is make parent project (Maven Reactor). So you will make new project and in that project define modules (Project A and Project B). You will reference that parent in Project A and Project B, and that will do the trick. Google maven parent to see how it's done.
After building Project B, maven will first build Project A and after that Project B.
Thing is your approach should work as well (just it's not a proper way to do it). So probably you are making mistake in groupId, version. You can check this by build Project A and then checking your local maven repository. Inside of it you should see folder structure if not something went wrong.
org/myurl/projectA-1.0.jar
Project strucuture is following:
project-parent
project-a
project-b
in project parent you define:
<groupId>foo.bar</groupId>
<artifactId>project-parent</artifactId>
<version>00.01-SNAPSHOT</version>
<name>FooBar:: Parent Project</name>
<packaging>pom</packaging>
<modules>
<module>../project-a</module>
<module>../project-b</module>
</modules>
in project-a and project-b you add:
<parent>
<groupId>foo.bar</groupId>
<artifactId>project-parent</artifactId>
<version>00.01-SNAPSHOT</version>
</parent>
In project-b you will have reference to project-a
<dependency>
<groupId>foo.bar</groupId>
<artifactId>project-a</artifactId>
<version>00.01-SNAPSHOT</version>
</dependency>
Once you build parent it should build all modules correctly. Don't use plugin, forget I said Maven Reactor :)
Related
We have a couple of legacy Java projects, which we converted to Maven projects / modules. Previously, all projects were NetBeans projects and had no real dependency management. External dependencies existed on the companies network drive and were directly included as JARs in the NetBeans projects of each module. For the internal dependencies, simple project references were used. It was a pain to build everything because the programmer had to build everything in the right order.
Now, we are in the position that we can open all the Maven modules in IntelliJ IDEA and NetBeans. However, I am having trouble figuring out the best way to combine the different modules and external dependencies in a specific way, which conforms to in-house plugin-like structure. Especially with NetBeans (developing with both IDEs must be possible).
Here is how the git repositories / project structure roughly looks like. The folder structure of the modules is the default Maven structure for each module. The list feature of this site was too clumsy, so I included it as screenshot...
We have an internal maven repository for the stuff and building with maven etc. is working. For Intellij IDEA i can run and debug the end product for customer1 via a custom run configuration, which copies the needed files in the needed structure:
With IntelliJ IDEA, I can debug the software, but I think that the approach (custom IntelliJ run config I created, pointing to all needed JARs and files directly) is rather ugly, and for NetBeans I could not find a similar "run configuration" mechanism.
So I tried to achieve this build process by creating a new "Customer1Runnable" Maven project as a sort of build description, which points to all needed Maven modules. Based on this, I believed I could achieve and automatism to create the needed software structure. Ergo copy all modules into a plugin folder and all dependencies of the modules into a lib folder inside the Customer1Runnable project, using the maven-assembly-plugin.
First off, is my assumption correct that this is a possible use case for the maven-assembly-plugin?
The project itself does not have any source files, it is only a pom.xml and the assembly-config.xml descriptor. I attached the assembly-plugin to the package phase. When running the mvn package command all connected modules are built, but for the execution of the assembly-plugin I get the following output:
For starters, I only tried to include one module in the assembly descriptor. This is the XML (opicom-assembly.xml) for it:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>opicom-assembly</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>my.company.reporting:module1</include>
</includes>
</moduleSet>
</moduleSets>
</assembly>
pom.xml of Customer1Runnable project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>1.6</version>
<groupId>my.company.customer1</groupId>
<artifactId>OpicomRunnable</artifactId>
<packaging>pom</packaging>
<name>OpicomRunnable</name>
<repositories>
<repository>
<id>Company-Maven-Repo</id>
<url>file:\\\\MyCompany\TFSDrop\MavenRepo</url>
</repository>
</repositories>
<modules>
<module>../my.company.customer1.module1</module>
<module>../my.company.customer1.module2</module>
.
.
.
<module>../../MyCompany_Common/Report/my.company.reporting.module1</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<inherited>true</inherited>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptors>
<descriptor>opicom-assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
</project>
The pom of a module looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my.company</groupId>
<artifactId>reporting</artifactId>
<version>1.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>module1</artifactId>
<version>1.3</version>
<packaging>jar</packaging>
<dependencies>
<!-- external dependencies -->
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<finalName>my-company-${project.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>../build</outputDirectory>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Thanks for any input on what I am doing wrong here / how to achieve this with Maven.
EDIT:
As requested, here an example project as ZIP-File.
https://drive.google.com/drive/folders/1ilJeTrOPgYgUTdOP0J4BQcBnPT5fls0k?usp=sharing
The parent directories ModuleGroupCustomer and ModuleGroupCommon do represent git repositories in the real scenario. The relative module path is caused, because the maven project which should be my "run config" points to maven projects in both repositories.
Maybe I am misunderstanding Maven in general? I thought of it in terms of use cases for dependency management similar to .Net nuget packages, but also as "project configuration" like ordinary NetBeans/Intellij projects.
Is it better to simply stick to the existing NetBeans projects for day to day development?
After a long and tedious process of trial and error, I have found a solution which is working for me. So I decided to share the solution online, in case someone else runs into a similar problem. Here is a link to the final zip archive containing working example projects => File CustomerRunnable_RunningAssemblyPluginStackoverflowExample.zip https://drive.google.com/drive/u/0/folders/1ilJeTrOPgYgUTdOP0J4BQcBnPT5fls0k
My error was that I misunderstood how the assembly-plugin works. The approach that I executed the plugin inside my aggregator pom (CustommerRunnable) is wrong, as this maven project only exists as parent pom.
The CustommerRunnable pom.xml references all customer plugins as modules. Those modules have not the CustommerRunnable as parent, but a different pom. Then I created a separate maven project "distribution". The pom.xml of the distribution defines all the plugins (needed customer maven modules) as dependencies. It also has the CustommerRunnable pom.xml as parent. Hence when I run the project in NetBeans, all connected modules are also build(if necessary).
It also configures the assembly plugin. The assembly plugin is attached to the maven package-phase and thus executed with it. It also uses a custom assembly descriptor, which copies all the previously defined plugins into the right folders. This is done by using dependencySets with include and exclude patterns.
See https://maven.apache.org/plugins/maven-assembly-plugin/advanced-descriptor-topics.html for details on this.
So one dependencySet copies all jar files of all plugins to a /plugin folder by using an include pattern. Then this approach is inversed to copy the jar files of all external dependencies to a /lib folder.
The descriptor also defines some extra files to copy to a particular location. exec-maven-plugin, so I can comfortably start the customer software out of NetBeans. I didn't yet manage to configure the execute plugin correctly regarding the needed classpath arguments.
Endresult looks like this:
It is also worth noting that the configurations of the "Build project", "Run project" and "Debug project" inside NetBeans need a tiny bit of modification. (Right Click Module "distribution" -> "Properties" -> point "Actions"
I am trying to mavenize an existing project.
I was able to build the EAR file(since i have to deploy in Websphere), When I try to deploy, using admin console - Able to install successfully , But application is not working, After investigating, I found the class files size is very less compare to the reference EAR file(old existing EAR file)
Steps I followed to build the EAR file
M2E plugin installed
Configure to Maven
Add ALL the jar files from lib folder like below(I read in SO, this is not the recommended way, but to complete the project, I have to do this)
<dependency>
<groupId>JarFile</groupId>
<artifactId>JarFile</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/WebContent/WEB-INF/lib/CRDBXMLExternal.jar</systemPath>
</dependency>
Added the relevant plugins (war, EAR)
Clean Build and Install.
ear file created. ear contains a war file, which has all the project related files including class,jsp etc.
I compared the folder structure with the existing EAR file and its contents , all look good. But only the size of class files(Not ALL but more than 80%) are varying. I use JD to decompile and see the code, Most of the code are not present, including imports.
If anyone has encountered similar issue , could you please tell me what am doing wrong here.
More Info
there are two project folders(both are maven) one will create WAR and another one EAR in EAR pom.xml
there is a dependency
<dependency>
<groupId>com.comp.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
Then there is a plugin
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<generatedDescriptorLocation>C:\COMP\Dev\may\repos\0.0.1-SNAPSHOT</generatedDescriptorLocation>
</configuration>
</plugin>
</plugins>
</build>
Adding WAR file building(Removed most of the dependencies kept only one sample) POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.comp.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>ABC</name>
<description>ABC</description>
<dependencies>
<!-- Local Repository -->
<dependency>
<groupId>com.ibm.ws.runtime</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/WebContent/WEB-INF/lib/com.ibm.ws.runtime.jar</systemPath>
</dependency>
</dependencies>
<repositories>
<repository>
<id>nexus-releases</id>
<name>nexus</name>
<url>http://abc-nexus.ldn.xyz.com:9080/nexus/content/groups/public/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- <warSourceDirectory>${project.basedir}\WebContent</warSourceDirectory> -->
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
The above does not tell Maven to package the EAR file with the lib directory dependency. It actually tells it to create local dependency on an existing JAR that is provided only at compile time. Thus, when you export the EAR, it does not include any of the JARs because it assumes that they are provided at runtime.
You should use the maven-ear-plugin which package an EAR file instead. You can find the full documentation here.
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.1</version>
</plugin>
The issue was,
web/WebContent/WEB-INF/classes is not getting updated.
but I could see the latest classes under web/target/classes path.
Now am checking why web/WebContent/WEB-INF/classes is not getting updated.
Just now got the Resolution from the below Link :-
ISSUE SOLVED by with the help of
https://coderanch.com/t/474423/ide/ecplise-doesn-create-classes-folder
Steps
Right click on your project -> build path -> Configure build path -> click on source tab -> click on browse (Default output folder).
After browsing click on WebContent -> Select WEB-INF -> Create new folder (called classes). it will open new window.
Give folder name as classes. Click on Advanced and give path of current classes folder means WEB-INF/classes.
After doing this, eclispe will rebuild your project and classes will be genenrated at WEB-INF/classes directory.
I have a project with a standard pom and jar packaging.
The standard -.jar is a desirable artifact of this project.
Additionally to the standard jar with all the classes of this project i need to create an additional jar only with the enums declared on it.
If i am abble to generate this jar in a maven standard with a different artifactId would be a plus.
This question here Create several jar files from single project using maven would be a good starting point but there is no answer
Any ideas?
Your best bet is to have a Maven multi-module build.
Typically, this consists of a single parent module plus multiple child modules.
The packaging of the parent module should be "pom" and it will only act as a container of the child modules.
The parent's pom.xml will look something like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>your groupID</groupId>
<artifactId>artifact</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Name</name>
<modules>
<module>submodule1</module>
<module>submodule2</module>
</modules>
</project>
Each module should be the name of a subdirectory. These subdirectories will contain their own pom.xml files.
Note that the groupId, artifactId, and version will be used later, so they should be something meaningful.
Your two child modules should look like normal jar packaging POM files with a few exceptions:
Each module should have a <parent> element points to the <groupId>, <artifactId>, and <version> of the parent module. While this section isn't strictly necessary, it does let you define common dependencies in the parent module.
The regular module will have the enum module as a dependency. You declare this just like any other dependency, but be aware that Maven compiles modules in order, so the enum module should be in the parent pom first.
I suggest you break your classes into two maven artifacts: one with the Enums and Interfaces as a dependency of the other which has your implementations. Since each has it's own POM you'll get two jars out of a build.
I end up using profiles to manage the solution solution. One managing the maven-jar-plugin plugin and other for the maven-source-plugin.
<profiles>
<profile>
<id>enum</id>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classifier>enum</classifier>
<includes>
<include>**/*Enum**</include>
<!-- or any other way to math my artifacts -->
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>enum-sources</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${mavenSourcePluginVersion}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
<configuration>
<classifier>enum-sources</classifier>
<includes>
<include>**/*Enum**</include>
<!-- or any other way to math my artifacts -->
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
In this way i can use
mvn install -Penum
to generate the jars with only the enums
and
mvn install -Penum-sources
to generate the jars with the sources.
to include this dependencies in other maven projects all you need is to specify the profile with classifier as in
<dependency>
<groupId>${groupId}</groupId>
<artifactId>{artifactId}</artifactId>
<version>${version}</version>
<classifier>enum</classifier>
</dependency>
<dependency>
<groupId>${groupId}</groupId>
<artifactId>{artifactId}</artifactId>
<version>${version}</version>
<classifier>enum-sources</classifier>
</dependency>
I have a war artefact and I need use some of their classes from a jar.
I can't move the classes to another project, then I deploy the classes and resources included in my webapp as an "attached" artifact using the following configuration:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
This will result in two artifacts being deployed: mywebapp-1.0-SNAPSHOT.war and mywebapp-1.0-SNAPSHOT-classes.jar.
To use those classes I Referencing the artifact as follows:
<dependency>
<groupId>mygroup</groupId>
<artifactId>mywebapp</artifactId>
<version>${project.version}</version>
<classifier>classes</classifier>
</dependency>
When I compiled from Jenkins everything works correctly, but when I run the tests locally from Eclipse can not find the reference classes. (java.lang.NoClassDefFoundError)
I think it might be a bug in the maven eclipse plugin, someone has any idea that can be happening?
Workaround is described on http://wiki.eclipse.org/M2E-WTP_FAQ:
A workaround exists though, we need to change the dependency whether the project is built in Eclipse or not. In your dependent project, you can configure the following :
<dependencies>
...
<dependency>
<groupId>com.company</groupId>
<artifactId>mywebapp</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>${webClassifier}</classifier>
</dependency>
...
</dependencies>
...
<properties>
...
<webClassifier>classes</webClassifier>
</properties>
...
<profiles>
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<webClassifier></webClassifier>
</properties>
</profile>
</profiles>
The m2e profile is automatically activated when the project is built with m2e, ignored in other circumstances. In that case only, the dependent project will use an empty classifier to reference the web project, which will be added to the classpath as expected.
My simple answer is the following link to the bug tracking system of Eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=365419
See the answers inside.
Yes it's a problem with Eclipse itself..
The solution within Eclipse just add the project manually within your workspace to the appropriate project where you need the classes out of your war project.
I have two projects in eclipse, both are maven controlled. A references B and they are on a flat system. What we currently have setup is that we have to a build on B - generate a jar on the system, and A references that jar.
I'd like to change this to be we just have to build A and it will go automatically build B? Can I do this in Maven/eclipse such that I don't have to create some higher project?
I have looked into some of the maven docs - but they just really confuse me :). Thanks for your help.
The pom's look like this
(B)
<project xmlns="..." xmlns:xsi="..."
xsi:schemaLocation="...">
<modelVersion>4.0.0</modelVersion>
<groupId>com.thetus</groupId>
<artifactId>irisMDK</artifactId>
<packaging>jar</packaging>
<name>irisMDK</name>
<version>0.1</version>
<url>...maven.apache...</url>
<build>
<sourceDirectory>java/src/main</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<testExcludes>
<exclude>**/*.java</exclude>
</testExcludes>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>java/src/main</directory>
</resource>
</resources>
</build>
<dependencies>
...
</dependencies>
</project>
------ And (A):
<project xmlns="..." xmlns:xsi="..."
xsi:schemaLocation="...">
<modelVersion>4.0.0</modelVersion>
<groupId>local.b</groupId>
<artifactId>projectB</artifactId>
<packaging>jar</packaging>
<name>B</name>
<version>RELEASE</version>
<url>...</url>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>...download.java.net/maven...</url>
</repository>
</repositories>
<build>
<plugins>
...
</plugins>
<sourceDirectory>java/src/main</sourceDirectory>
<testSourceDirectory>java/src/test</testSourceDirectory>
<resources>
</resources>
</build>
<dependencies>
<dependency>
<groupId>local.b</groupId>
<artifactId>projectB</artifactId>
<scope>system</scope>
<version>RELEASE</version>
<systemPath>${basedir}/../B/target/B-0.1.jar</systemPath>
</dependency>
...
</dependencies>
<reporting>
...
</reporting>
</project>
If you could show me an example of how to change ^^^ I would be most grateful!!
Original Answer:
The M2Eclipse plugin, if you are not using it already, allows you to do this. Once installed, remove
<systemPath>${basedir}/../B/target/B-0.1.jar</systemPath>
from A's pom.xml and make sure the groupid, artifactid, version match up with what is defined in B's pom.xml
Then right-click on the project, Maven-> Enable Dependency Resolution. The build should now look at B's local project
Edit:
If B's pom.xml looks like this (from your example):
<project xmlns="..." xmlns:xsi="..."
xsi:schemaLocation="...">
<modelVersion>4.0.0</modelVersion>
<groupId>com.thetus</groupId>
<artifactId>irisMDK</artifactId>
<packaging>jar</packaging>
<name>irisMDK</name>
<version>0.1</version>
...
</project>
In A's pom (which depends on Project B) your dependency should look like:
<project>
...
<dependencies>
<!--Attributes of project that this project is dependent upon, as defined in that projects POM -->
<dependency>
<groupId>com.thetus</groupId>
<artifactId>irisMDK</artifactId>
<version>0.1</version>
</dependency>
...
</dependencies>
....
</project>
This will tell maven and eclipse that project A explicitly depends on that version of Project B. With M2Eclipse, if you have a matching groupId, artifactId, and version in your workspace and you have "Dependency Resolution" enabled, Project B's contents will automatically be built and included into Project A.
Also, opening the Maven console in eclipse (console view->new console dropdown->new maven console) could help in debugging why project B isn't be picked up by Project A.
Sounds like you want to use a multi-module project, here is a simple tutorial. You would create a parent POM, and have both A and B as children, with A keeping its dependency on B.