I'm trying to have multiple package hierarchies in multiple locations in a Java project. To explain further: our own software is in the packages com.company.V2.*. I now want to add these external repositories:
org.freedesktop.dbus
org.freedesktop.NetworkManager
but unlike in previous versions of Netbeans, it seems there is no way to specify multiple directories for these separate packages. Under Project Properties, Sources, there is one setting Source Folder, which is where the com.company.V2.* hierarchy is. There is no way to say 'for com.company look in /dir1/dir2; for org.freedesktop.dbus look in /dir4/dirZ etc.' Obviously Netbeans can do this, because classes in the java.lang.* hierarchy are found, for example.
There are two consequences:
Maven cannot find the source when I build.
Netbeans cannot find the source when I control-click and shows multiple errors in the editor windows relating to methods having wrong parameters etc.
I've checked-out the two external repositories into the project root. I fixed the Maven problem by adding this to the POM:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>dbus-java/dbus-java/src/main/java</source>
<source>kk-dbus-nm-java/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
but this doesn't fix the editor window errors. It doesn't even fix the Maven problem properly because it is necessary to clean-and-rebuild (shift-F11) after each source change; otherwise I get a run-time error, which indicates to me that Maven isn't always finding stuff in the same place:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: org.freedesktop.dbus.connections.impl.DBusConnection.addSigHandler
at com.company.V2.net.Wifi.openBusConnection(Wifi.java:38)
at com.company.V2.net.Wifi.<clinit>(Wifi.java:23)
One way of fixing all this would be to use symlinks so that Maven and Netbeans see all packages in one hierarchy, but regrettably we have to support developers on Windoze / NTFS and in typical MS fashion, the simple matter of symlinking becomes ridiculously complicated under Windoze. I have created the symlinks and they solve all the problems given above, but I would prefer a 'proper' solution and not one involving a hacky workaround.
For the sake of anyone else looking, here is the best I have so far.
My project really only depends directly on org.freedesktop.NetworkManager, which in turn depends on org.freedesktop.dbus. So in my project pom.xml I have:
<repositories>
<repository>
<id>kk-dbus-nm-java</id>
<name>NetworkManager</name>
<url>file:///home/myself/projects/kk-dbus-nm-java</url>
</repository>
</repositories>
and
<dependency>
<groupId>kkdev.dbus</groupId>
<artifactId>org.freedesktop</artifactId>
<version>1.0-KKDev</version>
</dependency>
then /home/myself/projects/kk-dbus-nm-java/pom.xml is:
<?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>
<groupId>kkdev.dbus</groupId>
<artifactId>org.freedesktop</artifactId>
<version>1.0-KKDev</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.github.hypfvieh</groupId>
<artifactId>dbus-java</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
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 have just started with java dev. I am given a task of doing object serialization of avro format. I have broken my head trying different methods. The different IDEs and different tools, none of which have I been able to use to solve the issue, moreover they have made everything more complex and frustrating. I tried following a tutorial which didnt use an IDE per say but that was also unsuccessful as the Serialize.java class wasnt compiling. I'm presently trying to achieve the task using maven plugins and dependencies. I have just made a new Maven project on Intellij. This is my pom.xml where I have pasted the dependencies and plugins for avro format:
<?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>
<groupId>org.example</groupId>
<artifactId>avroTrial2</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.10.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.10.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
</project>
The second plugin shows an error, I have done the maven syncing on intellij and thats how the error from first plugin was rectified. Now the error being shown is : "Plugin 'org.apache.maven.plugins:maven-compiler-plugin:' not found". I need to deal with this error first before I can go and get stuck on some avro error after this.
This might be the reason behind it. The configuration part in the maven compiler plugin section and the properties basically do the same thing. You have configured twice and with different versions. It should be either one of them and in general should match with the java version you are using (more details could be found here.
This is not matching
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
with
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
and only use one of them.
I have encountered same problem so what I did to resolve it is:
Navigated to File->Settings in IntelliJ
Select Plugin from left bar and then I unchecked Maven plugin
Restarted the IDE
Again clicked on Plugin and checked Maven
Restarted the IDE
This question already has answers here:
Maven: add a dependency to a jar by relative path
(10 answers)
Closed 6 years ago.
Currently I'm having the problem that I have an Java project which was created with eclipse and which should now be builded with maven. I haven't created this project I just need to migrate it. The problem here is that I have a bunch of 3rd party jar's which need to be included to properly build the project. I know nothing about these jars (and I actually don't care what they do and where the came from).
I managed to find resources on how to add these jar's via command line to ma local repro and I further created a pom.xml which does the job for me (so I don#t need to use the command line) but somehow its not working properly. I doen't matter if I use the command line or the pom.xmo, non of the two approaches works for me. When i run the pom.xml
<?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>common</groupId>
<artifactId>common.master</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>common</groupId>
<artifactId>org.proj4j</artifactId>
<name>org.proj4j</name>
<version>0.1.0</version>
<packaging>jar</packaging>
<build>
<sourceDirectory>src/</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>install1</id>
<phase>package</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>proj4j-0.1.0.jar</file>
<groupId>common</groupId>
<artifactId>org.proj4j</artifactId>
<name>proj4j</name>
<version>0.1.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
<execution>
<id>install2</id>
<phase>package</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>proj4j-support-0.1.0.jar</file>
<groupId>common</groupId>
<artifactId>org.proj4j</artifactId>
<name>proj4j-support</name>
<version>0.1.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
the jars are put into my local repro under the specified group id, artifact ID etc. But the compiler still fails with an Unknown Symbol Error which says that the required class could not be found during compilation. I guess the reason are the artifact ID and the group ID because I came up with them. They are not related to my 3rd party jars at all. But I also don't know the proper group ID / artifact ID's because i know nothing about the jars. They are also partially self written by colleges.
What can I do to make maven find the required libs and to resolve all missing classes. Like I already said, with eclipse everything runs fine and without any problems. Shouldn't it be possible put the jar somehow into one folder in my local repro and tell the compiler If you search for anything start looking here ?
See if one of the below works for you:
How to add local jar files in maven project?
Maven: add a dependency to a jar by relative path let me know if it helps
They explain in details what needs to be done..
You can put your jar manually in your repo. You dont must know nothing about this jars, the artifact-id and the group-id affect the route in the repo and the name of the dependencie that compiler will look for.
I recommend you add some dependencie that exists in maven repo and observe the route and name of file that the pom creates in your local repo, after that sure you look the way that pom.xml works.
I have the following module structure:
powercontrol
powercontrol-core
pom.xml
powercontrol-data
pom.xml
powercontrol-gui
pom.xml
powercontrol-ui
pom.xml
pom.xml
Now I want that the GUI (Graphical User Interface) and UI (Command Line User Interface) can be executed by the client.
I tried to use the maven shade plugin inside the GUI and UI, but this makes it really a mess.
I prefer:
A jar file with all the third party dependencies (log4j etc).
A jar file (or maybe lib folder?) with all the project modules.
A'n executor for the GUI and UI.
Example:
powercontrol/
bin/
gui
ui
lib/
third-party.jar
powercontrol-core.jar
powercontrol-data.jar
powercontrol-gui.jar
powercontrol-ui.jar
I'm a bit stuck with getting a good structure now, where should I start?
All feedback, suggestions etc are welcome. Thank you in advance!
UPDATE 8/28/2015
I made a new module named: powercontrol-dist that will be executed as last in the Maven lifecycle. This module will generate a lib folder and copy all the dependencies from the powercontrol-gui and powercontrol-cli to this folder.
Now I have 2 questions!
Question 1
Is this a good way to go? Or is there a better way?
powercontrol-dist/pom.xml
<?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>nl.nberlijn.powercontrol</groupId>
<artifactId>powercontrol</artifactId>
<version>1.0</version>
</parent>
<artifactId>powercontrol-dist</artifactId>
<packaging>pom</packaging>
<name>PowerControl Dist</name>
<description>Dist</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>powercontrol-gui</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>powercontrol-cli</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Output:
powercontrol/
bin/
gui.exe
ui.exe
lib/
third-party-lib.....jar
third-party-lib.....jar
third-party-lib.....jar
powercontrol-core.jar
powercontrol-data.jar
powercontrol-gui.jar
powercontrol-cli.jar
Question 2
Also I want to make two .exe files "gui.exe and cli.exe" referencing to the powercontrol-gui.jar and the powercontrol-cli.jar.
Is adding a mainclass to the manifest inside the pom.xml in the powercontrol-gui and powercontrol-cli module enough?
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
If you want two executable JARs (gui.jar, ui.jar), you should add the shade plugin to those two modules, so that as part of each module, a standalone executable JAR is built. Both of the JARs will contain all the third-party stuff as well. You cannot create a standalone executable JAR where parts of the dependencies are in an external JAR (unless you do you own classloader magic or unless you also have to specify the external JAR on the command line).
If you are stuck with the maven shade plugin, you should tell us what problem exactly you have. Typically these can be resolved. A common problem is that certain files need to be "merged" when a shaded JAR is created, in particular files in META-INF e.g. used by Spring or by the Java Service Locator mechanism. The shade plugin offers support for such merging, but it needs to be configured for the case at hand.
Btw. I'd recommend calling the command line version "cli.jar" - "ui" sounds like "gui".
Ok, since you updated your question and now seem to be asking for a "native launcher" (exe file) instead of an executable JAR file - those are completely different things.
Launching an exe file from the command line:
C:\> gui
Launching an executable JAR file from the command line
C:\ java -jar gui.jar
To get the first, you need to create a native launcher that internally invokes Java. A project that might support you in that task could be launch4j - they also seem to provide a Maven plugin.
I have existing two maven projects, I want to combine them after build into one project.
I have not created these projects module wise, the two projects are separate maven projects.
Below is the POM xml code part from existing projects.
Project One pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-reg</artifactId>
<version>1.0</version>
<packaging>war</packaging>
Project Two pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-qba</artifactId>
<version>1.0</version>
<packaging>war</packaging>
Combine Project pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-war</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
I want to combine these projects into one like olex-war, A complete project.
After build I want all the code to be copied to this olex-war project.
Please suggest / provide hint if anyone aware of such scenario.
Thanks in advance.
You could start with a pom like this, that extract all the content of your old war files into content directory. Then you could package everything in that directory (except for web.xml and other metadata) in your new war.
<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>com.olex</groupId>
<artifactId>olex-war</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>olex-war Maven Webapp</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>olex-war</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.olex</groupId>
<artifactId>olex-qba</artifactId>
<version>${project.version}</version>
<packaging>war</packaging>
</artifactItem>
<artifactItem>
<groupId>com.olex</groupId>
<artifactId>olex-reg</artifactId>
<version>${project.version}</version>
<packaging>war</packaging>
</artifactItem>
</artifactItems>
<excludes>WEB-INF/web.xml</excludes>
<includes>**/*.class, **/*.jar, **/*.properties</includes>
<outputDirectory>${project.build.directory}/content</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
You should combine your projects manually. Many elements (like config files) need manual merging anyway and you want to avoid to accidentally loose something from one project because the other overwrites it quietly.
This would be a horrible mind-dulling task if there were not Version Control Systems to help you with the merging.
First set up a version control system (VCS). It will help in many other situations as well. I recommend git, but if you have another already up and running that should do it just fine, I won't use any fancy specials here.
Then create an empty folder for the new project and copy all the data from the first project into it. Do all replacements as you see fit (web.xml, pom.xml, other config files) and commit it to the VCS.
This will write this version of all files into the VCS and you cannot loose them again, so if you happen to make a mistake, no worries, just revert all changes back to this point.
Then copy the content of the second project over it overwriting everything thats duplicate.
Now you can use the "show differences" feature of your VCS to see what you'll need to merge. Most likely you can do so in a graphic tool so that makes it easy.
Most of them will be "unknown" that is, the new file does not exist in the VCS, yet. Most likely you can just add them to the VCS and be done with them.
More interesting are the ones that are "modified". That means the file already existed and the other project contained them as well. You will have to merge them into a combined version that is from now on valid for your new project.
When you are done you should have all the files (including pom.xml) necessary for the new project ready. Commit them to the VCS to not loose this state in the future.