0

I have a local java application that I have recently converted to a Maven project. My goal is to add my recently converted maven project to another Maven project as a dependency in Eclipse STS.

The temporary path of the recently converted maven project is C:\Users\nconnor2\Desktop and the path of the soon-to-be parent Maven project is C:\Users\nconnor2\Desktop\adoudrepo.

I'm really struglling to wrap my head around how maven works when dealing with local maven project.

The pom of my new maven project is

<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>TB2TUBSync</groupId>
  <artifactId>TB2TUBSync</artifactId>
  <version>1.5</version>
</project>

The pom of my soon-to-be parent Maven project 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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.bellmts</groupId>
    <artifactId>test</artifactId>
    <name>TB2TUBSyncWeb</name>
    <packaging>war</packaging>
    <version>1.0.0-SNAPSHOT</version>

What I have been trying to do is to include my new maven project as a module in my soon-to-be parent maven project but I get an error that I can't include a module in another maven project with war packaging.

At the end of the day I need to access methods from TB2TUBSync (new maven) in TB2TUBSyncWeb (soon-to-be parent maven).

Nicolasome
  • 341
  • 1
  • 3
  • 21
  • Those are snippets of POMs, right? You're tailing the first and truncating the second. – ingyhere Jul 03 '19 at 22:29
  • @ingyhere they are, I just added the full contents of the first Pom, the second Pom is very lengthy. I don’t think the remainder of the Pom will be relevant to this question so I truncated the content of the POm to keep my question brief. – Nicolasome Jul 03 '19 at 22:33
  • https://stackoverflow.com/a/10090564/325452 – ingyhere Jul 03 '19 at 22:43
  • https://stackoverflow.com/a/31220514/325452 – ingyhere Jul 03 '19 at 22:44

1 Answers1

1

You'll want to leverage the WAR Plugin to generate both JARs and the WAR file, then you can publish the jars to your local repository with mvn clean install. At that point you can import them into the other POM with dependency resolution.

It's detailed at https://eureka.ykyuen.info/2009/10/30/maven-dependency-on-jarwar-package/ .

ingyhere
  • 11,818
  • 3
  • 38
  • 52