Maven loads external dependency packages

  maven

Order

Not all jar packages can be downloaded in maven warehouse, and some scenarios are not easy to use private warehouse, so how can these external JARs be managed through maven?

Using maven-install-plugin

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>

Example

In the root directory of maven project, create a new lib folder with a demo.jar under management.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
                <executions>
                    <execution>
                        <id>install-demo-jar</id>
                        <phase>clean</phase>
                        <configuration>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>com.example</groupId>
                            <artifactId>demojar</artifactId>
                            <version>1.0.0</version>
                            <file>${project.basedir}/lib/demo.jar</file>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Installation

mvn clean install

Add dependency

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>demojar</artifactId>
            <version>1.0.0</version>
        </dependency>

This is the end of the story and can be typed as fat jar.

doc