Search in sources :

Example 31 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project gate-core by GateNLP.

the class SimpleMavenCache method main.

public static void main(String[] args) throws Exception {
    for (RemoteRepository repo : Utils.getRepositoryList()) {
        System.out.println(repo);
    }
    Artifact artifactObj = new DefaultArtifact("uk.ac.gate.plugins", "annie", "jar", "8.5-SNAPSHOT");
    // artifactObj = artifactObj.setFile(
    // new File("/home/mark/.m2/repository/uk/ac/gate/plugins/annie/8.5-SNAPSHOT/annie-8.5-SNAPSHOT.jar"));
    SimpleMavenCache reader = new SimpleMavenCache(new File("repo"));
    System.out.println(reader.findArtifact(artifactObj));
    System.out.println(reader.findVersions(artifactObj));
    reader.cacheArtifact(artifactObj);
    System.out.println(reader.findArtifact(artifactObj));
    System.out.println(reader.findVersions(artifactObj));
    reader = new SimpleMavenCache(new File("repo2"), new File("repo"));
    System.out.println(reader.findArtifact(artifactObj));
    System.out.println(reader.findVersions(artifactObj));
}
Also used : RemoteRepository(org.eclipse.aether.repository.RemoteRepository) File(java.io.File) SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 32 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project gate-core by GateNLP.

the class SimpleMavenCache method cacheParents.

private void cacheParents(File pom, RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository> repos) throws ModelBuildingException, IOException, ArtifactResolutionException {
    ModelBuildingRequest req = new DefaultModelBuildingRequest();
    req.setProcessPlugins(false);
    req.setPomFile(pom);
    req.setModelResolver(new SimpleModelResolver(repoSystem, repoSession, repos));
    req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
    ModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance();
    Model model = modelBuilder.build(req).getEffectiveModel();
    Parent parent = model.getParent();
    if (parent == null)
        return;
    Artifact pomArtifact = new DefaultArtifact(parent.getGroupId(), parent.getArtifactId(), "pom", parent.getVersion());
    ArtifactRequest artifactRequest = new ArtifactRequest(pomArtifact, repos, null);
    ArtifactResult artifactResult = repoSystem.resolveArtifact(repoSession, artifactRequest);
    // but copy it to a file named for the original requested version number
    File file = getArtifactFile(artifactRequest.getArtifact());
    FileUtils.copyFile(artifactResult.getArtifact().getFile(), file);
    cacheParents(artifactResult.getArtifact().getFile(), repoSystem, repoSession, repos);
}
Also used : DefaultModelBuilderFactory(org.apache.maven.model.building.DefaultModelBuilderFactory) ModelBuildingRequest(org.apache.maven.model.building.ModelBuildingRequest) DefaultModelBuildingRequest(org.apache.maven.model.building.DefaultModelBuildingRequest) ModelBuilder(org.apache.maven.model.building.ModelBuilder) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) Parent(org.apache.maven.model.Parent) DefaultModelBuildingRequest(org.apache.maven.model.building.DefaultModelBuildingRequest) Model(org.apache.maven.model.Model) File(java.io.File) SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 33 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project launcher by runelite.

the class Launcher method main.

public static void main(String[] args) throws Exception {
    OptionParser parser = new OptionParser();
    parser.accepts("version").withRequiredArg();
    parser.accepts("clientargs").withRequiredArg();
    parser.accepts("nojvm");
    parser.accepts("debug");
    OptionSet options = parser.parse(args);
    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception ex) {
        logger.warn("Unable to set cross platform look and feel", ex);
    }
    LauncherFrame frame = new LauncherFrame();
    Bootstrap bootstrap = getBootstrap();
    // update packr vmargs
    PackrConfig.updateLauncherArgs(bootstrap);
    if (options.has("version")) {
        String version = (String) options.valueOf("version");
        logger.info("Using version {}", version);
        DefaultArtifact artifact = bootstrap.getClient();
        artifact = (DefaultArtifact) artifact.setVersion(version);
        bootstrap.setClient(artifact);
        // non-releases are not signed
        verify = false;
    }
    ArtifactResolver resolver = new ArtifactResolver(REPO_DIR);
    resolver.setListener(frame);
    resolver.addRepositories();
    Artifact a = bootstrap.getClient();
    List<ArtifactResult> results = resolver.resolveArtifacts(a);
    if (results.isEmpty()) {
        logger.error("Unable to resolve artifacts");
        return;
    }
    try {
        verifyJarSignature(results.get(0).getArtifact().getFile());
        logger.info("Verified signature of {}", results.get(0).getArtifact());
    } catch (CertificateException | IOException | SecurityException ex) {
        if (verify) {
            logger.error("Unable to verify signature of jar file", ex);
            return;
        } else {
            logger.warn("Unable to verify signature of jar file", ex);
        }
    }
    frame.setVisible(false);
    frame.dispose();
    String clientArgs = getArgs(options);
    // packr doesn't let us specify command line arguments
    if ("true".equals(System.getProperty("runelite.launcher.nojvm")) || options.has("nojvm")) {
        ReflectionLauncher.launch(results, clientArgs, options);
    } else {
        JvmLauncher.launch(bootstrap, results, clientArgs, options);
    }
}
Also used : CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) OptionParser(joptsimple.OptionParser) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) Bootstrap(net.runelite.launcher.beans.Bootstrap) OptionSet(joptsimple.OptionSet) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 34 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project launcher by runelite.

the class ArtifactResolverTest method printJson.

@Test
public void printJson() {
    Bootstrap b = new Bootstrap();
    Gson g = new Gson();
    DefaultArtifact a = new DefaultArtifact("net.runelite", "client", "", "jar", "1.0.0-SNAPSHOT");
    b.setClient(a);
    b.setClientJvmArguments(new String[] { "-Xmx256m", "-Xss2m", "-Dsun.java2d.noddraw=true", "-XX:CompileThreshold=1500", "-Xincgc", "-XX:+UseConcMarkSweepGC", "-XX:+UseParNewGC" });
    System.out.println(g.toJson(b));
}
Also used : Bootstrap(net.runelite.launcher.beans.Bootstrap) Gson(com.google.gson.Gson) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Test(org.junit.Test)

Example 35 with DefaultArtifact

use of org.eclipse.aether.artifact.DefaultArtifact in project launcher by runelite.

the class ArtifactResolverTest method test.

@Test
@Ignore
public void test() throws Exception {
    ArtifactResolver resolver = new ArtifactResolver(folder.newFolder());
    resolver.addRepositories();
    Artifact a = new DefaultArtifact("net.runelite", "client", "", "jar", "1.0.0-SNAPSHOT");
    List<ArtifactResult> artifacts = resolver.resolveArtifacts(a);
    for (ArtifactResult a2 : artifacts) System.out.println(a2.getArtifact().getFile());
}
Also used : DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)110 Artifact (org.eclipse.aether.artifact.Artifact)70 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)42 File (java.io.File)39 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)34 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)29 IOException (java.io.IOException)24 Dependency (org.eclipse.aether.graph.Dependency)23 ArrayList (java.util.ArrayList)16 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)13 CollectRequest (org.eclipse.aether.collection.CollectRequest)12 VersionRangeRequest (org.eclipse.aether.resolution.VersionRangeRequest)12 VersionRangeResolutionException (org.eclipse.aether.resolution.VersionRangeResolutionException)12 VersionRangeResult (org.eclipse.aether.resolution.VersionRangeResult)12 SubArtifact (org.eclipse.aether.util.artifact.SubArtifact)12 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)11 ArtifactDescriptorException (org.eclipse.aether.resolution.ArtifactDescriptorException)10 Version (org.eclipse.aether.version.Version)10 Model (org.apache.maven.model.Model)9 RepositorySystem (org.eclipse.aether.RepositorySystem)9