Hello. There is such a problem. It is necessary for the project to use the library jzy3d (for plotting, if specifically). I do not understand how to connect the library to the project. Everywhere I read what I need through Maven, but after reading various websites by Maven, I still can’t understand how I can connect it all the same?

The course of my actions: As far as I understood, Maven is needed -> I create a new Maven project. I am writing code there that I found on the site of this library itself . The code itself is -> (it may have been written incorrectly, because as I said, I don’t understand yet)

<?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.jzy3d</groupId> <artifactId>jzy3d-api</artifactId> <version>0.9.2-SNAPSHOT</version> <repositories> <repository> <id>jzy3d-snapshots</id> <name>Jzy3d Snapshots</name> <url>http://maven.jzy3d.org/snapshots</url> </repository> <repository> <id>jzy3d-releases</id> <name>Jzy3d Snapshots</name> <url>http://maven.jzy3d.org/releases</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.jzy3d</groupId> <artifactId>jzy3d-api</artifactId> <version>0.9.2-SNAPSHOT</version> </dependency> </dependencies> </project> 

And here is the actual question, what should I do next? Does this code need to be compiled (well, or another action)? And how can I add it to my (other) project? enter image description here With Maven faced for the first time in this form, help out. If it is possible, in more detail, for I understand that I do not display this topic yet.

    1 answer 1

    With Maven, it's really not easy, he has a lot of opportunities. In order for the library to be in your project, then in this project you also need to use Maven. Just create a pom in the root. It will fit perfectly into your project, the only thing that you need to correctly write the source directory and java version.

    Compiling and packaging is also desirable through maven, using mvn clean install. (or compile, or package, all this can be done through idea). Your jar will automatically form. Then, at the release stage, you may come across a shade plugin that allows you to enable dependencies in jar (by default, they are not included).

    Another plus is an excellent support in the idea, you do not need to manually compile anything, just import the maven project, and already through the green arrow it will start fine.

    There is also an alternative option - in the idea in the project structure menu you can go to artifacts and download the lib directly from the maven repository. And then connect it to the modules. But I strongly recommend this option to you, so when loading this whole thing into git repo, for example, you will have to connect it again or through idea (perhaps this can be bypassed, it creates its own xml files, but personally it didn't work for me and I had to do everything with my hands

    • To be honest, I still did not quite understand what to do. Ie I just need to create a pom.xml file in the root of the project, and not the whole Maven project? - Maxim
    • Yes, you simply create pom.xml and write in it <build> correct <sourceDirectory> and <directory>. If I'm not mistaken, the first one you will have is src, and the second out - Uraty
    • Understood, thank you very much. Understood. It turned out to do what I wanted. I understood that Maven is a powerful and not very simple tool) - Maxim