#How to import multi-module maven project from local .m2 repository?

77 messages Β· Page 1 of 1 (latest)

fathom trout
#

Hey πŸ‘‹

I'm currently working on https://github.com/catppuccin/java which has recently been refactored to be a multi-module maven project, details are as follows:

  • catppuccin-java: parent pom/module (v2.0.0)
  • catppuccin-palette: child module (v2.0.0)
  • catppuccin-processing: child module (v.1.0.0)

Building and packaging this results in a success, as shown below:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] catppuccin-java 2.0.0 .............................. SUCCESS [  0.720 s]
[INFO] catppuccin-processing 1.0.0 ........................ SUCCESS [  1.952 s]
[INFO] catppuccin-palette 2.0.0 ........................... SUCCESS [  1.814 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.956 s
[INFO] Finished at: 2024-05-18T14:42:00+01:00
[INFO] ------------------------------------------------------------------------

Before publishing to maven central, I wanted to make sure that it could be imported into another project, so I ran ./mvnw clean install -U and it resulted in a success, the following files are now present in my local .m2 repository:

β”Œ repository/com/catppuccin  󱃾 default/vikunja
β”” $ tree -L 3
.
β”œβ”€β”€ catppuccin-java
β”‚Β Β  β”œβ”€β”€ 2.0.0
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-java-2.0.0.pom
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-java-2.0.0.pom.asc
β”‚Β Β  β”‚Β Β  └── _remote.repositories
β”‚Β Β  └── maven-metadata-local.xml
β”œβ”€β”€ catppuccin-palette
β”‚Β Β  β”œβ”€β”€ 2.0.0
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0.jar
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0.jar.asc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0-javadoc.jar
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0-javadoc.jar.asc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0.pom
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0.pom.asc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0-sources.jar
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ catppuccin-palette-2.0.0-sources.jar.asc
β”‚Β Β  β”‚Β Β  └── _remote.repositories
β”‚Β Β  └── maven-metadata-local.xml
└── catppuccin-processing
    β”œβ”€β”€ 1.0.0
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0.jar
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0.jar.asc
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0-javadoc.jar
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0-javadoc.jar.asc
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0.pom
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0.pom.asc
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0-sources.jar
    β”‚Β Β  β”œβ”€β”€ catppuccin-processing-1.0.0-sources.jar.asc
    β”‚Β Β  └── _remote.repositories
    └── maven-metadata-local.xml

6 directories, 24 files

So I booted up an older codebase and put this into my pom.xml:

        <dependency>
            <groupId>com.catppuccin</groupId>
            <artifactId>catppuccin-java</artifactId>
            <version>2.0.0</version>
        </dependency>

Unfortunately, I keep getting the following error:

Could not find artifact com.catppuccin:catppuccin-java:jar:2.0.0 in central (https://repo.maven.apache.org/maven2)

I've made sure that the files exist, I've tried to inject the child modules, I've reindexed the local repository in Intellij, etc. I'm honestly at my wits end. Can anyone help me understand how to import the dependency from my local .m2 repository without going to Maven Central? I'd really appreciate it!

GitHub

β˜• Soothing pastel theme for Java. Contribute to catppuccin/java development by creating an account on GitHub.

midnight elmBOT
#

βŒ› This post has been reserved for your question.

Hey @fathom trout! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

fathom trout
#

Some more things I've tried is the -o flag for offline only builds that seems to error too

opaque lark
#

u said u wanted to test it BEFORE publishing to m2
and the error its giving u says "cannot find it on m2"
this does not surprise me

there is a way to define a local folder as a repository to look in for downloads, give that a try for ur pre-publish test pull

fathom trout
#

Indeed, I was under the impression that your local .m2 repository is always queried before going to Maven Central

opaque lark
#

(i did it once for a repo i didnt want to publish) but i can remember exact details atm

#

ur checks in ur local if u have the data cached ...... but there is nothing upstream to have a cached copy of

fathom trout
#

Oh interesting, so it won't find any repositories that don't at least have a version in Maven Central

vestal terrace
#

are you sure your local maven repo is at the correct path and maven searches it? that the artefact is correct?

#

i think there's a way to tell maven to always look at the local repo

vestal terrace
#

also try deleting the _remote.repositories files, maven apparently also checks those

fathom trout
#

Yeah I did that too

fathom trout
#

Looks like I've just operating under the wrong assumption

fathom trout
#

Mhm tried that a while back when looking at a SO post with that same solution

#

The libraries that I've tested before were always single jar so I would just import them using Intellij and not bother with the poms

#

Since this was a multi module one, tried going the maven route and yeah it's been a bit painful lol

vestal terrace
#

it's trying to get a jar artefact from the dependency, but catppuccin-java doesn't have one. try catppuccin-processing

fathom trout
#

The confidence that I really want is to understand how the maven GAV coordinates would be formed for the multi module

#

like will this work once it's on maven central?

        <dependency>
            <groupId>com.catppuccin</groupId>
            <artifactId>catppuccin-java</artifactId>
            <version>2.0.0</version>
        </dependency>
vestal terrace
#

i dont think so if its trying to get the jar artefact while it doesnt have one

#

what does the pom look like

fathom trout
#

You can view the child poms by going into the palette/processing directories

#

We've had a successful publish up to nexus staging, I just wanted to see the jar(s) being imported locally via maven on a codebase before going all the way. hence this forum post lol

vestal terrace
#

you might want to make a BOM in that case, a bill of materials. what does the actual pom in your local repo for catppuccin-java look like?

#

it doesnt have to be the same pom as source, that's why im asking

fathom trout
maiden sphinx
#

Hi, from your first post we can see that "catppuccin-java" does not have any artifact. That is the reason why Maven try to search for it in Maven central

fathom trout
#

Looks like they're the same

#

(left is from .m2, right is the source repo)

vestal terrace
fathom trout
fathom trout
#

Although, I thought the current catppuccin-java pom.xml acted as a BOM πŸ€”

midnight elmBOT
vestal terrace
#

not really, it's the parent pom

#

parent pom and bom are different things, as funny as it sounds

fathom trout
#

Hmmm but not mutually exclusive?

#

As in, a BOM can be a parent pom

vestal terrace
#

eh kind of, its hard to make a parent pom a bom

fathom trout
#

Just reading through the article you linked now

vestal terrace
#

parent pom has the <modules>, a bom just references other dependencies that should be imported when using the bom in a project

fathom trout
#

I see, I'm trying to think what's the easiest way forward for our usecase

#

I figured the current config would work with these gav coordinates below:

        <dependency>
            <groupId>com.catppuccin</groupId>
            <artifactId>catppuccin-java</artifactId>
            <version>2.0.0</version>
        </dependency>
``` But your comment earlier is interesting
fathom trout
#

and that should mean you should be able to just import catppuccin-palette directory since your effective POM would be everything from the BOM and the palette's own pom.xml

vestal terrace
#

if you do the bom approach, you will have an extra module with all of the dependencies of the project and nothing more in it. you will have to publish parent and all modules including the bom. users will then import the bom and get everything

fathom trout
#

So, the first iteration of this project resulted in one single catppuccin-palette jar, which is currently published on maven central

#

Now we've done effectively a v2 rewrite which now has 2 modules, catppuccin-palette and catppuccin-processing and a parent catppuccin-java

#

I'm trying to understand how that impacts what users would now see on maven central when we publish. Initially I wanted to only upload the palette and processing JARs but I believe we need the parent catppuccin-java pom.xml since it is the parent

vestal terrace
#

yes, correct

#

catppuccin-java is referenced as parent pom by all the modules, so it needs to be there to provide additional metadata

fathom trout
#

Right so does that mean the user now has to explicitly pull in catppuccin-java and catppuccin-palette into their own pom.xml?

vestal terrace
#

catppuccin-palette would pull in catppuccin-java, but that'd have no effect since -java has no actual artefacts in it

#

so no, they wouldnt have to manually add catppuccin-java

fathom trout
#

Right of course, so users should just be able to write

        <dependency>
            <groupId>com.catppuccin</groupId>
            <artifactId>catppuccin-palette</artifactId>
            <version>2.0.0</version>
        </dependency>
vestal terrace
#

yes

fathom trout
#

And that is irrespective of whether we convert our current catppuccin-java pom.xml to a BOM?

#

It seems like what we have currently should work then once published to maven central?

vestal terrace
#

which pom are you talking about? the one of catppuccin-palette?

#

the bom only makes sense when you want to provide a way for multiple dependencies to be imported in one dependency, if you have several modules that you think make sense together

#

if you just want users to include one or optionally both dependencies when needed, a bom doesnt make much sense. what you have now is good for that purpose

#

users can just pull in -palette or -processing at will, which will then as a result pull in -java as parent pom (which has no effect, but maven resolves it for metadata)

fathom trout
#

Right, that gives me the confidence I needed

#

Thanks for taking your time out to reply

midnight elmBOT
# fathom trout Thanks for taking your time out to reply

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

fathom trout
#

Appreciate the help, have a good day!