开发者

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 ver开发者_开发技巧sion and I'd like don't change it.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜