简体   繁体   中英

how to add external library (jar) + sources (zip) to pom.xml using maven-install-plugin?

i found an good article on the internet that shows me how to add a jar library to my maven (eclipse) project, using "maven-install-plugin". i used this and managedd it to have the ucanaccess 3.0.1 library added to my maven project.

however, the source code is a separate zip file and i did not find any sufficient information on the internet how to add this source file "the same way" using "maven-install-plugin". i found some information that the plugin "somehow" supports the definition of sources, but i was unable to find WHERE and HOW the proper way is (no examples found).

Could someone please give me a Tip what a proper "maven-install-plugin" configuration in a pom.xml would look like including the SOURCE FILE ?

This is part of my pom.xml concerning the external library ucanaccess 3:

                <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install-external</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/externalLibs/UCanAccess-3.0.1-bin/ucanaccess-3.0.1.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>net.ucanaccess</groupId>
                            <artifactId>ucanaccess</artifactId>
                            <version>3.0.1</version>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

thanks

I added UCanAccess to the maven central repository this week (it's my first time). Is there a reason to rebuild it from the source files? If not you shouldn't need any workaround but you could include it in your pom as any other dependency. The groupid is net.sf.ucanaccess the artifactid is ucanaccess. I'm an old italian man so any feedback about it would be very appreciated (maybe my seven year old daughter wouldn't have had the same trouble with maven).

Use custom repository based on filesystem, like this:

<repositories>
  <repository>
  <id>local</id>
    <layout>default</layout>
    <url>file:///${project.basedir}/localrepo</url>
  </repository>
</repositories>

So Maven will look for the files in the local repo and the copy them to ~/.m2/repository

no additional plugins required. You just need to put the files into the correct folders, like localrepo/com/mypackage/something/library-1.0.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM