MAVEN FOR JAVA
What is Maven?
It is a build and dependency management for Java
Let's get started
Maven is a built tool used as java's build management tool.
- The POM(project object model ): The file detailing a Maven project and its addictions. AllJava project that uses Maven has its root directory with a POM file.The pom.xmldescribes the dependencies of theproject, and tells us how to create it.
- The directory: The structured format used to define a Maven project within POM.
- Repositories: Where software is stored and found by third parties.
Hosting your project in a Maven repository
While building a project that will be a dependency--say, creating a library for other projects to use-- So one will need to make it available in one of four ways:
- Make it available locally.
- Publish to a privately managed remote repository.
- Publish to a cloud-based private repository.
- Publish to a public repository like Maven Central.
Build the Maven package
If we create a pom.xml and put it in a directory, we will be able to run Maven commands against it. Maven has multiple numbers of commands, and more are available via a plugin, but we only need to know a handful to start.
For your first command, we can try executing mvn package.
Maven's directory structure
When the command is done, we can see that Maven has created a /target directory, which is the standard location for any of your project's output. Dependencies that we've downloaded will reside in the /target directory, along with our compiled application.
In the next step, we want to add a Java file, which we can place in the Maven src/ directory. Create a /src/main/java/com/javaworld/Hello.java file,
Hello.java
Comments
Post a Comment