How to Search in Maven Central

By Group or Artifact ID

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuider.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=sample&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

By Group ID

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=g:br.eti.fernandoribeiro.sample&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

By Artifact ID

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=a:mavencentralapi-sample&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

By Group ID and Artifact ID

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=g:br.eti.fernandoribeiro.sample%20AND%20a:mavencentralapi-sample&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

By Group ID, Artifact ID, Version, Classifier and Packaging

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=g:br.eti.fernandoribeiro.sample%20AND%20a:mavencentralapi-sample%20AND%20v:1.0%20AND%20I:javadoc%20AND%20p:jar&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

By Class Name

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=c:MavenCentralApiSample&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

By FQCN

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=fc:br.eti.fernandoribeiro.sample.mavencentralapi.MavenCentralApiSample&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

By SHA-1 Checksum

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class MavenCentralSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("http://search.maven.org/solrsearch/select?q=1:35379fb6526fd019f331542b4e9ae2e566c57933&rows=20&wt=json").get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.