English 中文(简体)
How to manually disable/blacklist Maven repository
原标题:

In my base project I use dependency of JasperReports which has non-existent repository declaration in its pom. When I run every Maven commad there is dependency looking for commons-collection in this Jasper repository so I need to wait for timeout.
This is my base project and is used as dependency in my others projects so again I need to wait for timeout.
Is there are a way to move this repository to blacklisted or override this settings?

Notes:
1.Why it search in Jasper repository, maybe bacause of ranges

<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>[2.1,)</version>
    <scope>compile</scope>
</dependency>

2.My idea to resolve this problem is to change jasper pom and use proxy repository, but I looking to another option.
3.I use jasperreports 1.3.3 version and I d like don t change it.

最佳回答

Is there a way to move this repository to blacklisted or override this settings?

To my knowledge, this is not possible.

Why does it search in Jasper repository, maybe because of ranges

Yes, I think ranges are "responsible" here of this behavior. Without ranges, Maven wouldn t have to check remote repositories for a newer version than the one available in your local repo.

My idea to resolve this problem is to change jasper pom and use proxy repository, but I looking to another option.

Fixing jasper pom and using a proxy repository would of course be the ideal solution but this is not always possible. There is maybe a workaround though. Did you try to exclude jasperreports s transitive dependencies that have ranges and to provide them yourself (with fixed version) in your pom instead. Something like this:

<dependencies>
  <dependency>
    <groupId>jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>1.3.3</version>
    <!-- Remove Transitive dependencies drawn by Jasper Report that we don t want -->
    <exclusions>
      <exclusion>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
      </exclusion>
      ...
    </exclusions>
  </dependency>
  <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>2.1</version><!-- Or whatever version, as long as it s fixed -->
    <scope>compile</scope>
  </dependency>
  ....
<dependencies>

This way, Maven shouldn t have to check the non existent repository and this should avoid having to wait for the timeout. I d give it a try.

I use jasperreports 1.3.3 version and I d like don t change it.

No problem.

问题回答

Wouldn t the following tell maven to ignore a specific repository:

    <repository>
        <id>repo1.maven</id>
        <url>http://repo1.maven.org</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

You can override a repo by using a mirrorOf declaration in your settings.xml. Although that not what it s typically intended for, setting for example a mirrorOf on the jasper reports repoid and point it at Central (repo1.maven.org) would effectively make it disappear.

A better option is to use a repository manager like Nexus and then you can control what proxies and artifacts are actually served.





相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签