jcabi / jcabi-aether

Wrapper of Sonatype Aether
http://aether.jcabi.com/
Other
66 stars 33 forks source link

Fetching artifacts from https://jitpack.io is broken #106

Open mirceanis opened 4 years ago

mirceanis commented 4 years ago

I'm trying to fetch some artifacts from https://jitpack.io I used the example code on https://aether.jcabi.com/ and replaced the repository and artifact coordinates like so:

import com.jcabi.aether.Aether;

import java.io.File;
import java.util.Arrays;
import java.util.Collection;

import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.resolution.DependencyResolutionException;
import org.sonatype.aether.util.artifact.DefaultArtifact;

public class Main {
    public static void main(String[] args) throws DependencyResolutionException {
        File local = new File("/tmp/local-repository");
        Collection<RemoteRepository> remotes = Arrays.asList(
                new RemoteRepository("jitpack", "default", "https://jitpack.io"),
                new RemoteRepository("jcenter", "default", "https://jcenter.bintray.com/")
        );
        Collection<Artifact> deps = new Aether(remotes, local).resolve(
                new DefaultArtifact("com.github.uport-project:kmnid:0.4.2"),
                "runtime"
        );
    }
}

This code fails with the following exception:

Exception in thread "main" org.sonatype.aether.resolution.DependencyResolutionException: failed to load 'com.github.uport-project:kmnid:jar:0.4.2 (runtime)' from ["jitpack (https://jitpack.io, releases+snapshots) without authentication"] into /tmp/local-repository
    at com.jcabi.aether.Aether.fetch(Aether.java:237)
    at com.jcabi.aether.Aether.resolve_aroundBody2(Aether.java:180)
    at com.jcabi.aether.Aether$AjcClosure3.run(Aether.java:1)
    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
    at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:208)
    at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1)
    at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:136)
    at com.jcabi.aether.Aether.resolve(Aether.java:177)
    at com.jcabi.aether.Aether.resolve_aroundBody0(Aether.java:163)
    at com.jcabi.aether.Aether$AjcClosure1.run(Aether.java:1)
    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
    at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:208)
    at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1)
    at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:136)
    at com.jcabi.aether.Aether.resolve(Aether.java:156)
    at Main.main(Main.java:20)
Caused by: java.lang.IllegalArgumentException: failed to load 'com.github.uport-project:kmnid:jar:0.4.2 (runtime)' from ["jitpack (https://jitpack.io, releases+snapshots) without authentication"] into /tmp/local-repository
    ... 16 more
Caused by: java.lang.NullPointerException
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:352)
    at com.jcabi.aether.Aether.fetch(Aether.java:228)
    ... 15 more

It seems to point to Aether.fetch() which leads to a dead end as it indicates a bug in the sonatype dependency which is unmaintained.

Please indicate any possible workaround you may think of or any hint of a fix.

0crat commented 4 years ago

@yegor256/z please, pay attention to this issue

JDFind commented 4 years ago

+1