1

I'm trying to run a GitHub repo that uses Java and Maven, but I ran into an error while using mvn clean install. I would ask this question in the GitHub thread (linked below), but the author hasn't responded to previous issues. When I run the command I get this error:

Failed to execute goal on project tu: Could not resolve dependencies for project com.vaguehope.tu:tu:jar:1.1-SNAPSHOT: Failed to collect dependencies at args4j:args4j:jar:2.0.21: Failed to read artifact descriptor for args4j:args4j:jar:2.0.21: Could not transfer artifact args4j:args4j:pom:2.0.21 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [maven.jenkins-ci.org (http://maven.jenkins-ci.org/content/repositories/releases/, default, releases)] -> [Help 1]

Here is the pom file:

<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.vaguehope.tu</groupId>
    <artifactId>tu</artifactId>
    <version>1.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>tu</name>

    <properties>
        <java.version>1.7</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <args4j.version>2.0.21</args4j.version>
        <commonsio.version>2.4</commonsio.version>
        <logback.version>1.0.9</logback.version>
        <slf4j.version>1.7.2</slf4j.version>
        <junit.version>4.11</junit.version>
        <hamcrest.version>1.3</hamcrest.version>
        <mockito.version>1.9.5</mockito.version>
        <powermock.version>1.5</powermock.version>
    </properties>

    <prerequisites>
        <maven>2.2.1</maven>
    </prerequisites>

    <build>
        <plugins>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.vaguehope.tu.Main</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>assembly</id>
                        <phase>install</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <repositories>

        <repository>
            <id>maven.jenkins-ci.org</id>
            <url>http://maven.jenkins-ci.org/content/repositories/releases/</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

    </repositories>

    <dependencies>

        <!-- CLI -->

        <dependency>
            <groupId>args4j</groupId>
            <artifactId>args4j</artifactId>
            <version>${args4j.version}</version>
        </dependency>

        <!-- Util -->

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commonsio.version}</version>
        </dependency>

        <!-- Logging -->

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <!-- Testing. -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>


    </dependencies>

</project>

Here is the original GitHub post:
https://github.com/haku/tu

Matt
  • 12,848
  • 2
  • 31
  • 53
AshMan
  • 19
  • 1
  • 4
  • https://maven.apache.org/docs/3.8.1/release-notes.html#how-to-fix-when-i-get-a-http-repository-blocked – xerx593 Jun 07 '21 at 16:40

3 Answers3

0

Seems the repository URL is not accessible .

Try updating the repo URL to maven central:

https://repo1.maven.org/maven2

Remove the repositories tag basically from pom.xml.
Share settings.xml if it doesn't help.

Tarun
  • 685
  • 3
  • 16
0

The problem is that HTTP repositories are blocked by default since this change to Maven. Maven developers are trying to force people to use HTTPS. This happened a long time after that repo was last touched 4 years ago, which is why the original authors had no problems. See also: How to disable maven blocking external HTTP repositores?

It seems maven.jenkins-ci.org doesn't exist any more anyway. You can trivially remove the whole dependency on that repo by bumping this version from 2.0.21 to 2.0.22. The latter exists in Maven Central, and the former does not - hence why the original author(s) needed to add a separate repo declaration to get it from somewhere else.

<args4j.version>2.0.22</args4j.version>

Then you can delete the whole <repositories> section

<repositories>
    <repository>
        <id>maven.jenkins-ci.org</id>
        <url>http://maven.jenkins-ci.org/content/repositories/releases/</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
Michael
  • 41,989
  • 11
  • 82
  • 128
  • Thanks for the help, but I fixed this by changing "maven.jenkins-ci.org" to "repo.jenkins-ci.org" and changing the http in the links to https. And instead of version 2.0.21, I fetched 2.0.2 instead – AshMan Jun 08 '21 at 17:12
0

A different solution, related to a corporate environment, is that we are slowly moving out of maven to another dep/build tool, but there is still a 'corporate' settings.xml file defined.

So just rename it to a different file (instead of deleting), like mv settings.xml settings-backup.xml, and returning maven again, would help you to check if it's the issue.

Johnny
  • 14,397
  • 15
  • 77
  • 118