#Creating an External Library via Maven

1 messages · Page 1 of 1 (latest)

last mango
#

@livid moss

#

alright

#

so I set up the project, now I know I have to modify the pom.xml file to support dependencies but not sure exactly what to put

livid moss
#

First off, did you install the library that you made to your local repo?

I.E. Did you run maven install?

last mango
#

No

#

again I am completely clueless as to how this works lol

livid moss
#

Are you using intellij?

last mango
#

yep

#

oh i figured it out

livid moss
#

Ok, so there should be a tab on the right side labeled Maven.

last mango
#

just ran it

#

alright, so I got a build now

livid moss
#

Ok. so now you need to go to your other project that will depend on your library.

#

In your pom, you need to add that library as a dependency.

#

This can be done just like any other dependency.

last mango
#

so both my projects (library and plugin) need to be maven projects right

#

if the plugin isn't can I just add it as a module

livid moss
#

Yes

last mango
#

oh alright

livid moss
#

I haven't really used IntelliJ modules before, but maven modules are a little more complex.

#

For your case, I'd stick with separate projects.

last mango
#

okay, I turned it into a maven project

livid moss
#

Maven modules are really for projects that have internal things that could be swapped. The most common usecase for spigot plugin development is server versioning.

I.E. 1.18.2 vs 1.17.2

#

Two different versions, which the submodules can switch between.

#

Since you are creating a library, you'd want it to be a separate project.

#

That way, you don't end up compiling it into every project that depends on it.

last mango
#

So, to add it as a dependency, what do I put in these fields?

livid moss
#

The values that you put in your library's pom.xml.

last mango
#

so these?

livid moss
#

Yes.

If you look at your library's pom, you;ll see the same exact fields. Take those values and put it in your project's pom as the values for the new dependency.

last mango
#

well yes, the screenshot above is of the library's fields, and I've now copied them in, what's next?

livid moss
#

You'll want to push this button on the maven tab.

#

That way, the project can update the pom.

last mango
#

yep, did it

livid moss
#

If you aren't getting any errors, then you're all set. You can now use all of the classes that are in the library.

last mango
#

oh dang

#

alright lemme test it

#

Okay, well I'm trying to add spigot as a dependency as well but it seems like it doesn't recognize the version

livid moss
#

Spigot is a weird case. You'll need to run BuildTools in order for it to work with maven.

#

?buildtools

#

?bt

#

Hmm

#

1 sec

#

Spigot can't be distributed through the maven repos, so you have to install it manually.

last mango
#

so I run java -jar BuildTools.jar --rev 1.18.2 in the maven goal executor?

livid moss
#

The reason why is due to the legal issues that Bukkit brought about when it got DMCA'ed all that time ago.

livid moss
last mango
#

or did you mean command prompt

livid moss
#

Command Prompt.

You also need to download the jar and run the command in the same directory that the jar file is.

#

Or write the path to the jar.

last mango
#

Same error

livid moss
#

You need to navigate to the directory that BuildTools is in.

Alternatively, you could just open command prompt in the same directory with the right click menu.

#

You may need to Shift + Right Click.

last mango
#

well doesn't that mean I need to download BuildTools first

livid moss
#

Yes

#

Otherwise, you are trying to tell your computer to run something that doesn't exist.

last mango
#

so I'll just download Java 17