element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Documents Loading non-repo jars with Maven
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: PEarle
  • Date Created: 7 Jul 2016 1:56 PM Date Created
  • Last Updated Last Updated: 6 Oct 2021 8:51 PM
  • Views 1089 views
  • Likes 1 like
  • Comments 2 comments
Related
Recommended

Loading non-repo jars with Maven

A circumstance may arise whereby a jar file is required for a project which is not in maven. This has happened recently in a project I worked on which requires a Websphere MQ jar, which is not available via maven.

 

The jar can be included into the project as follows - the main steps are

  • Deploy the jar to a file location within the project
  • Use the maven-install-plugin to load the jar from the file system rather than from the maven repo
  • Dependencies are defined in pom.xml as normal (see version number below)

 

Deploy jar file to project location

 

The jar file needs to be deployed to a repo location - maven has a command to do this as follows ;

 

mvn install:install-file -Dfile=<jar_file_to_deploy> -DgroupId=<groupid> -DartifactId=<?artifactid?> -Dversion=<version> -Dpackaging=jar -DlocalRepositoryPath=<deployment_location>

 

E.g. for the mq.jar, which is group id com.ibm, artifact id mq use the following command

 

mvn install:install-file -Dfile=C:\peter\mqjms-9.0.jar -DgroupId=com.ibm -DartifactId=mq -Dversion=9.0 -Dpackaging=jar -DlocalRepositoryPath=E:\Repos\Git\mqbridge\repo

 

Note the version - this is set artificially high to ensure hat it doesn not conflict with any pre-existing maven version

 

maven-install-plugin

The pom.xml file needs to know that it should load the jar file from the file store, rather than from the maven repository. This can be achieved as shown below.

Note that multiple executions are used for multiple files. It should be noted that the files are loaded during the install-file phase of the build - to ensure that this goal is implemented, the project should be built with the 'clean' parameter (e.g. mvn clean install)

 

<plugin>
    <artifactId>maven-install-plugin</artifactId>
    <executions>
        <execution>
            <id>install-mq</id>
            <phase>process-resources</phase>
            <goals>
                <goal>install-file</goal>
            </goals>
            <configuration>
                <groupId>com.ibm</groupId>
                <artifactId>mq</artifactId>
                <version>9.0</version>
                <packaging>jar</packaging>
                <file>${project.basedir}/repo/com/ibm/mq/9.0/mq-9.0.jar</file>
            </configuration>
        </execution>
        <execution>
            <id>install-mqjms</id>
            <phase>process-resources</phase>
            <goals>
                <goal>install-file</goal>
            </goals>
            <configuration>
                <groupId>com.ibm</groupId>
                <artifactId>mqjms</artifactId>
                <version>9.0</version>
                <packaging>jar</packaging>
                <file>${project.basedir}/repo/com/ibm/mqjms/9.0/mqjms-9.0.jar</file>
            </configuration>
        </execution>
    </executions>
</plugin>

 

 

Define dependencies

 

Dependencies are defined as normal - the version number should match the version used when the jar file was deployed to the file system (see above).

E.g.

<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>mq</artifactId>
    <version>9.0</version>
</dependency>
<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>mqjms</artifactId>
    <version>9.0</version>
</dependency>

  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
  • PEarle
    PEarle over 9 years ago in reply to clem57

    This is part of a client application which needs to send Jms messages to Websphere MQ - hence the Websphere components in the example. Its just an example though image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 9 years ago

    Websphere is mainly a messaging protocol used within the context of mainframes. So how was this deployed?

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube