private static Settings buildSettings(
      SettingsBuilder builder,
      MavenServerSettings settings,
      Properties systemProperties,
      Properties userProperties)
      throws RemoteException {
    SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
    settingsRequest.setGlobalSettingsFile(settings.getGlobalSettingsFile());
    settingsRequest.setUserSettingsFile(settings.getUserSettingsFile());
    settingsRequest.setSystemProperties(systemProperties);
    settingsRequest.setUserProperties(userProperties);

    Settings result = new Settings();
    try {
      result = builder.build(settingsRequest).getEffectiveSettings();
    } catch (SettingsBuildingException e) {
      Maven3ServerGlobals.getLogger().info(e);
    }

    if (settings.getLocalRepository() != null) {
      result.setLocalRepository(settings.getLocalRepository().getPath());
    }

    if (result.getLocalRepository() == null) {
      result.setLocalRepository(
          new File(SystemProperties.getUserHome(), ".m2/repository").getPath());
    }

    return result;
  }
  public InputStream getInputStream() throws CoreException {
    if (filePath != null) {
      File file = new File(filePath);
      if (file.isFile()) {
        IMaven maven = MavenPlugin.getDefault().getMaven();
        Settings settings = maven.buildSettings(null, filePath);

        List<Server> servers = settings.getServers();
        if (servers != null) {
          for (Server server : servers) {
            server.setUsername(obfuscate(server.getUsername()));
            server.setPassword(obfuscate(server.getPassword()));
            server.setPassphrase(obfuscate(server.getPassphrase()));
          }
        }

        List<Proxy> proxies = settings.getProxies();
        if (proxies != null) {
          for (Proxy proxy : proxies) {
            proxy.setUsername(obfuscate(proxy.getUsername()));
            proxy.setPassword(obfuscate(proxy.getPassword()));
          }
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream(1024 * 4);
        maven.writeSettings(settings, baos);
        return new ByteArrayInputStream(baos.toByteArray());
      }
    }
    return null;
  }
  @Test
  public void autoDiscoverWithOneCompleteLocationFromMirrorWithEncryptedPassword()
      throws NexusDiscoveryException {
    Settings settings = new Settings();

    String url = "http://nexus.somewhere.com/";

    testClientManager.testUrl = url;
    testClientManager.testUser = "******";
    testClientManager.testPassword = "******";

    Mirror mirror = new Mirror();
    mirror.setId("some-mirror");
    mirror.setName("A Mirror");
    mirror.setUrl(url);

    settings.addMirror(mirror);

    Server server = new Server();
    server.setId("some-mirror");
    server.setUsername("user");
    server.setPassword(encryptedPassword);

    settings.addServer(server);

    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId("group.id");
    model.setArtifactId("artifact-id");
    model.setVersion("1");

    MavenProject project = new MavenProject(model);

    discovery.discover(settings, project, "blah", true);
  }
  private RemoteRepository convertToArtifactRepository(
      final org.apache.maven.artifact.repository.ArtifactRepository artifactRepository) {
    final MavenEmbedder mavenEmbedder =
        MavenProjectLoader.newMavenEmbedder(MavenSettings.getSettings().isOffline());
    final RemoteRepository.Builder remoteRepoBuilder =
        new RemoteRepository.Builder(
                artifactRepository.getId(),
                artifactRepository.getLayout().getId(),
                artifactRepository.getUrl())
            .setSnapshotPolicy(
                new RepositoryPolicy(
                    true,
                    RepositoryPolicy.UPDATE_POLICY_DAILY,
                    RepositoryPolicy.CHECKSUM_POLICY_WARN))
            .setReleasePolicy(
                new RepositoryPolicy(
                    true,
                    RepositoryPolicy.UPDATE_POLICY_ALWAYS,
                    RepositoryPolicy.CHECKSUM_POLICY_WARN));

    final Settings settings = MavenSettings.getSettings();
    final Server server = settings.getServer(artifactRepository.getId());

    if (server != null) {
      final Authentication authentication =
          mavenEmbedder
              .getMavenSession()
              .getRepositorySession()
              .getAuthenticationSelector()
              .getAuthentication(remoteRepoBuilder.build());
      remoteRepoBuilder.setAuthentication(authentication);
    }

    return remoteRepoBuilder.build();
  }
  private AuthenticationSelector getAuthSelector() {
    DefaultAuthenticationSelector selector = new DefaultAuthenticationSelector();

    Collection<String> ids = new HashSet<String>();
    for (Authentication auth : authentications) {
      List<String> servers = auth.getServers();
      if (!servers.isEmpty()) {
        org.sonatype.aether.repository.Authentication a = ConverterUtils.toAuthentication(auth);
        for (String server : servers) {
          if (ids.add(server)) {
            selector.add(server, a);
          }
        }
      }
    }

    Settings settings = getSettings();
    for (Server server : settings.getServers()) {
      org.sonatype.aether.repository.Authentication auth =
          new org.sonatype.aether.repository.Authentication(
              server.getUsername(), server.getPassword(),
              server.getPrivateKey(), server.getPassphrase());
      selector.add(server.getId(), auth);
    }

    return new ConservativeAuthenticationSelector(selector);
  }
  private File getDefaultLocalRepoDir() {
    if (mavenRepoDirFromProperty != null) {
      return mavenRepoDirFromProperty;
    }

    Settings settings = getSettings();
    if (settings.getLocalRepository() != null) {
      return new File(settings.getLocalRepository());
    }

    return new File(new File(project.getProperty("user.home"), ".m2"), "repository");
  }
 private Settings settingsWithJettyRepository() {
   Settings settings = new Settings();
   Profile defaultProfile = new Profile();
   defaultProfile.setId("default");
   Repository repo1 = new Repository();
   repo1.setId("repo1");
   repo1.setUrl("http://localhost:" + port + "/repository");
   defaultProfile.addRepository(repo1);
   settings.addProfile(defaultProfile);
   settings.addActiveProfile("default");
   return settings;
 }
 private Settings settingsForRepository(String id, String url) {
   Settings settings = new Settings();
   Profile profile = new Profile();
   profile.setId("test");
   Repository repo = new Repository();
   repo.setId(id);
   repo.setUrl(url);
   profile.addRepository(repo);
   settings.addProfile(profile);
   settings.addActiveProfile("test");
   return settings;
 }
Exemplo n.º 9
0
  // adds local repository
  private Settings enrichWithLocalRepository(Settings settings) {

    // set default value if not set at all
    if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) {
      settings.setLocalRepository(DEFAULT_REPOSITORY_PATH);
    }

    // override any value with system property based location
    String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
    if (altLocalRepository != null && altLocalRepository.length() > 0) {
      settings.setLocalRepository(altLocalRepository);
    }
    return settings;
  }
 private Settings settingsWithUnresponsiveRepository() {
   Settings settings = new Settings();
   Profile defaultProfile = new Profile();
   defaultProfile.setId("default");
   Repository repo1 = new Repository();
   repo1.setId("repo1");
   // see:
   //  - https://tools.ietf.org/html/rfc5737
   //  - https://en.wikipedia.org/wiki/Reserved_IP_addresses
   repo1.setUrl("http://192.0.2.0/repository");
   defaultProfile.addRepository(repo1);
   settings.addProfile(defaultProfile);
   settings.addActiveProfile("default");
   return settings;
 }
Exemplo n.º 11
0
  protected ClientConfiguration getClientConfiguration() {
    ClientConfiguration clientConfiguration =
        new ClientConfiguration().withUserAgent(getUserAgent());

    if (null != this.settings && null != settings.getActiveProxy()) {
      Proxy proxy = settings.getActiveProxy();

      clientConfiguration.setProxyHost(proxy.getHost());
      clientConfiguration.setProxyUsername(proxy.getUsername());
      clientConfiguration.setProxyPassword(proxy.getPassword());
      clientConfiguration.setProxyPort(proxy.getPort());
    }

    return clientConfiguration;
  }
 /**
  * Returns the list of servers with decrypted passwords.
  *
  * @return list of servers with decrypted passwords.
  */
 List<Server> getDecryptedServers() {
   final SettingsDecryptionRequest settingsDecryptionRequest =
       new DefaultSettingsDecryptionRequest();
   settingsDecryptionRequest.setServers(settings.getServers());
   final SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(settingsDecryptionRequest);
   return decrypt.getServers();
 }
  public RepositorySystemSession newSystemSession(RepositorySystem sys, Settings settings) {
    DefaultRepositorySystemSession session = new MavenRepositorySystemSession();

    Map<String, Object> configProps = new LinkedHashMap<String, Object>();
    putAllEnvProperties(configProps);
    session.setConfigProperties(configProps);

    session.setOffline(settings.isOffline());
    // session.setUserProperties(settings.getUserProperties());

    LocalRepository localRepo = new LocalRepository(getDefaultLocalRepoDir(settings));
    session.setLocalRepositoryManager(sys.newLocalRepositoryManager(localRepo));

    // session.setProxySelector(getProxySelector());
    session.setMirrorSelector(getMirrorSelector(settings));
    // session.setAuthenticationSelector(getAuthSelector());

    session.setCache(new DefaultRepositoryCache());

    // session.setRepositoryListener(new AntRepositoryListener(task));

    // session.setWorkspaceReader(ProjectWorkspaceReader.getInstance());

    return session;
  }
 private ArtifactRepository createLocalRepository(
     MavenServerSettings.UpdatePolicy snapshotUpdatePolicy) {
   try {
     return getComponent(RepositorySystem.class)
         .createLocalRepository(new File(myMavenSettings.getLocalRepository()));
   } catch (InvalidRepositoryException e) {
     throw new RuntimeException(e);
     // Legacy code.
   }
   // ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
   // ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
   //
   // String url = myMavenSettings.getLocalRepository();
   // if (!url.startsWith("file:")) url = "file://" + url;
   //
   // ArtifactRepository localRepository = factory.createArtifactRepository("local", url, layout,
   // null, null);
   //
   // boolean snapshotPolicySet = myMavenSettings.isOffline();
   // if (!snapshotPolicySet && snapshotUpdatePolicy ==
   // MavenServerSettings.UpdatePolicy.ALWAYS_UPDATE) {
   //  factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
   // }
   // factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
   //
   // return localRepository;
 }
Exemplo n.º 15
0
  /**
   * Get server with given id
   *
   * @param settings
   * @param serverId must be non-null and non-empty
   * @return server or null if none matching
   */
  protected Server getServer(final Settings settings, final String serverId) {
    if (settings == null) return null;
    List<Server> servers = settings.getServers();
    if (servers == null || servers.isEmpty()) return null;

    for (Server server : servers) if (serverId.equals(server.getId())) return server;
    return null;
  }
Exemplo n.º 16
0
 private boolean hasServerSettings() {
   if (serverId == null) {
     return false;
   } else {
     final Server srv = settings.getServer(serverId);
     return srv != null;
   }
 }
Exemplo n.º 17
0
  // adds offline mode from system property
  private Settings enrichWithOfflineMode(Settings settings) {

    String goOffline = SecurityActions.getProperty(ALT_MAVEN_OFFLINE);
    if (goOffline != null && goOffline.length() > 0) {
      settings.setOffline(Boolean.valueOf(goOffline));
    }

    return settings;
  }
Exemplo n.º 18
0
  /**
   * Gets proxy selector
   *
   * @return the selector
   */
  public ProxySelector proxySelector() {
    DefaultProxySelector dps = new DefaultProxySelector();

    for (Proxy proxy : settings.getProxies()) {
      dps.add(MavenConverter.asProxy(proxy), proxy.getNonProxyHosts());
    }

    return dps;
  }
  @Test
  public void promptWithTwoPotentialLocationsFromMirrors() throws NexusDiscoveryException {
    Settings settings = new Settings();

    String url = "http://nexus.somewhere.com/";
    String user = "******";
    String password = "******";

    testClientManager.testUrl = url;
    testClientManager.testUser = user;
    testClientManager.testPassword = password;

    Mirror mirror = new Mirror();
    mirror.setId("some-mirror");
    mirror.setName("A Mirror");
    mirror.setUrl(url);

    settings.addMirror(mirror);

    Mirror mirror2 = new Mirror();
    mirror2.setId("some-other-mirror");
    mirror2.setName("Another Mirror");
    mirror2.setUrl("http://nexus.somewhere-else.com/");

    settings.addMirror(mirror2);

    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId("group.id");
    model.setArtifactId("artifact-id");
    model.setVersion("1");

    MavenProject project = new MavenProject(model);

    prompter.addExpectation("1", "http://nexus.somewhere.com/", "Selection:");
    prompter.addExpectation("Enter Username", user);
    prompter.addExpectation("Enter Password", password);

    NexusConnectionInfo info = discovery.discover(settings, project, "blah", false);
    assertNotNull(info);
    assertEquals(url, info.getNexusUrl());
    assertEquals(user, info.getUser());
    assertEquals(password, info.getPassword());
  }
  @Test
  public void autoDiscoverWithOneCompleteLocationFromSnapshotPOMDistMgmt()
      throws NexusDiscoveryException {
    Settings settings = new Settings();

    String url = "http://nexus.somewhere.com/";
    String id = "some-mirror";
    String user = "******";
    String password = "******";

    testClientManager.testUrl = url;
    testClientManager.testUser = user;
    testClientManager.testPassword = password;

    Server server = new Server();
    server.setId(id);
    server.setUsername(user);
    server.setPassword(password);

    settings.addServer(server);

    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId("group.id");
    model.setArtifactId("artifact-id");
    model.setVersion("1-SNAPSHOT");

    DistributionManagement dm = new DistributionManagement();

    DeploymentRepository repo = new DeploymentRepository();
    repo.setId(id);
    repo.setUrl(url);

    dm.setSnapshotRepository(repo);

    model.setDistributionManagement(dm);

    MavenProject project = new MavenProject(model);

    project.setArtifact(factory.create(project));

    discovery.discover(settings, project, "blah", true);
  }
Exemplo n.º 21
0
  public Maven(
      @Nullable Metadata.Repository snapshotsRepositoryInfo,
      @Nullable Metadata.Repository releasesRepositoryInfo)
      throws SettingsBuildingException {
    validateRepositoryMetadata(snapshotsRepositoryInfo, "snapshots");
    validateRepositoryMetadata(releasesRepositoryInfo, "releases");

    final SettingsBuildingRequest request =
        new DefaultSettingsBuildingRequest()
            .setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE)
            .setUserSettingsFile(DEFAULT_USER_SETTINGS_FILE)
            .setSystemProperties(System.getProperties());

    Settings settings =
        new DefaultSettingsBuilderFactory().newInstance().build(request).getEffectiveSettings();

    repositorySystem =
        new DefaultServiceLocator()
            .addService(RepositoryConnectorFactory.class, AsyncRepositoryConnectorFactory.class)
            .addService(RepositoryConnectorFactory.class, FileRepositoryConnectorFactory.class)
            .addService(VersionResolver.class, DefaultVersionResolver.class)
            .addService(VersionRangeResolver.class, DefaultVersionRangeResolver.class)
            .addService(ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class)
            .addService(MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class)
            .getService(RepositorySystem.class);

    String localRepository = settings.getLocalRepository();
    if (localRepository == null || localRepository.trim().isEmpty()) {
      localRepository = new File(MAVEN_USER_HOME, "repository").getAbsolutePath();
    }

    session =
        new MavenRepositorySystemSession()
            .setLocalRepositoryManager(
                repositorySystem.newLocalRepositoryManager(new LocalRepository(localRepository)));

    releasesRepository =
        makeRemoteRepository(
            releasesRepositoryInfo, settings.getServer(releasesRepositoryInfo.getId()), false);
    snapshotsRepository =
        makeRemoteRepository(
            snapshotsRepositoryInfo, settings.getServer(snapshotsRepositoryInfo.getId()), true);
  }
Exemplo n.º 22
0
  /**
   * Gets manager for local repository
   *
   * @return the manager
   */
  public LocalRepositoryManager localRepositoryManager(
      final RepositorySystemSession session, boolean legacyLocalRepository) {
    Validate.notNull(session, "session must be specified");
    String localRepositoryPath = settings.getLocalRepository();
    Validate.notNullOrEmpty(localRepositoryPath, "Path to a local repository must be defined");

    SWRLocalRepositoryManager factory = SWRLocalRepositoryManager.ENHANCED;
    // here we rely either on system property or flag passed by caller
    if (useLegacyLocalRepository || legacyLocalRepository) {
      factory = SWRLocalRepositoryManager.LEGACY;
    }
    if (settings.isOffline()) {
      factory = SWRLocalRepositoryManager.SIMPLE;
    }

    LocalRepositoryManager manager =
        factory.localRepositoryManager(system, session, new File(localRepositoryPath));
    return manager;
  }
 @Test
 public void getLocalRepositoryFromSettings() throws MalformedURLException {
   PropertyResolver propertyResolver = createMock(PropertyResolver.class);
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.localRepository"))
       .andReturn(null)
       .atLeastOnce();
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.settings")).andReturn(null);
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.useFallbackRepositories")).andReturn(null);
   Settings settings = createMock(Settings.class);
   expect(settings.getLocalRepository()).andReturn("file:somewhere/localrepository/");
   replay(propertyResolver, settings);
   MavenConfigurationImpl config = new MavenConfigurationImpl(propertyResolver, PID);
   config.setSettings(settings);
   assertEquals(
       "Local repository",
       new URL("file:somewhere/localrepository/"),
       config.getLocalRepository().getURL());
   verify(propertyResolver, settings);
 }
  @Test
  public void autoDiscoverWithOneCompleteLocationFromSettingsProfileRepoWithConfirmation()
      throws NexusDiscoveryException {
    Settings settings = new Settings();

    String url = "http://nexus.somewhere.com/";
    String id = "some-mirror";
    String user = "******";
    String password = "******";

    testClientManager.testUrl = url;
    testClientManager.testUser = user;
    testClientManager.testPassword = password;

    Server server = new Server();
    server.setId(id);
    server.setUsername(user);
    server.setPassword(password);

    settings.addServer(server);

    org.apache.maven.settings.Repository repo = new org.apache.maven.settings.Repository();
    repo.setId(id);
    repo.setUrl(url);
    repo.setName("Profile Repository");

    org.apache.maven.settings.Profile profile = new org.apache.maven.settings.Profile();
    profile.addRepository(repo);

    settings.addProfile(profile);

    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId("group.id");
    model.setArtifactId("artifact-id");
    model.setVersion("1");

    MavenProject project = new MavenProject(model);

    prompter.addExpectation("Use this connection?", "y");
    discovery.discover(settings, project, "blah", false);
  }
Exemplo n.º 25
0
  private synchronized Settings getSettings() {
    if (settings == null) {
      DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
      request.setUserSettingsFile(getUserSettings());
      request.setGlobalSettingsFile(getGlobalSettings());
      request.setSystemProperties(getSystemProperties());
      request.setUserProperties(getUserProperties());

      try {
        settings = settingsBuilder.build(request).getEffectiveSettings();
      } catch (SettingsBuildingException e) {
        project.log("Could not process settings.xml: " + e.getMessage(), e, Project.MSG_WARN);
      }

      SettingsDecryptionResult result =
          settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(settings));
      settings.setServers(result.getServers());
      settings.setProxies(result.getProxies());
    }
    return settings;
  }
Exemplo n.º 26
0
  private MirrorSelector getMirrorSelector() {
    DefaultMirrorSelector selector = new DefaultMirrorSelector();

    for (Mirror mirror : mirrors) {
      selector.add(
          mirror.getId(), mirror.getUrl(), mirror.getType(), false, mirror.getMirrorOf(), null);
    }

    Settings settings = getSettings();
    for (org.apache.maven.settings.Mirror mirror : settings.getMirrors()) {
      selector.add(
          String.valueOf(mirror.getId()),
          mirror.getUrl(),
          mirror.getLayout(),
          false,
          mirror.getMirrorOf(),
          mirror.getMirrorOfLayouts());
    }

    return selector;
  }
Exemplo n.º 27
0
  public Model loadModel(
      Task task, File pomFile, boolean local, RemoteRepositories remoteRepositories) {
    RepositorySystemSession session = getSession(task, null);

    remoteRepositories =
        remoteRepositories == null
            ? AetherUtils.getDefaultRepositories(project)
            : remoteRepositories;

    List<org.sonatype.aether.repository.RemoteRepository> repositories =
        ConverterUtils.toRepositories(
            task.getProject(), session, remoteRepositories, getRemoteRepoMan());

    ModelResolver modelResolver =
        new AntModelResolver(session, "project", getSystem(), getRemoteRepoMan(), repositories);

    Settings settings = getSettings();

    try {
      DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
      request.setLocationTracking(true);
      request.setProcessPlugins(false);
      if (local) {
        request.setPomFile(pomFile);
        request.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_STRICT);
      } else {
        request.setModelSource(new FileModelSource(pomFile));
        request.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
      }
      request.setSystemProperties(getSystemProperties());
      request.setUserProperties(getUserProperties());
      request.setProfiles(SettingsUtils.convert(settings.getProfiles()));
      request.setActiveProfileIds(settings.getActiveProfiles());
      request.setModelResolver(modelResolver);
      return modelBuilder.build(request).getEffectiveModel();
    } catch (ModelBuildingException e) {
      throw new BuildException("Could not load POM " + pomFile + ": " + e.getMessage(), e);
    }
  }
  private MirrorSelector getMirrorSelector(Settings settings) {
    DefaultMirrorSelector selector = new DefaultMirrorSelector();
    for (Mirror mirror : settings.getMirrors()) {
      selector.add(
          String.valueOf(mirror.getId()),
          mirror.getUrl(),
          mirror.getLayout(),
          false,
          mirror.getMirrorOf(),
          mirror.getMirrorOfLayouts());
    }

    return selector;
  }
Exemplo n.º 29
0
  private ProxySelector getProxySelector() {
    DefaultProxySelector selector = new DefaultProxySelector();

    for (Proxy proxy : proxies) {
      selector.add(ConverterUtils.toProxy(proxy), proxy.getNonProxyHosts());
    }

    Settings settings = getSettings();
    for (org.apache.maven.settings.Proxy proxy : settings.getProxies()) {
      org.sonatype.aether.repository.Authentication auth = null;
      if (proxy.getUsername() != null || proxy.getPassword() != null) {
        auth =
            new org.sonatype.aether.repository.Authentication(
                proxy.getUsername(), proxy.getPassword());
      }
      selector.add(
          new org.sonatype.aether.repository.Proxy(
              proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth),
          proxy.getNonProxyHosts());
    }

    return selector;
  }
  @Test
  public void autoDiscoverWithOneCompleteLocationFromPOMRepo() throws NexusDiscoveryException {
    Settings settings = new Settings();

    String url = "http://nexus.somewhere.com/";
    String id = "some-mirror";
    String user = "******";
    String password = "******";

    testClientManager.testUrl = url;
    testClientManager.testUser = user;
    testClientManager.testPassword = password;

    Server server = new Server();
    server.setId(id);
    server.setUsername(user);
    server.setPassword(password);

    settings.addServer(server);

    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setGroupId("group.id");
    model.setArtifactId("artifact-id");
    model.setVersion("1");

    Repository repo = new Repository();
    repo.setId(id);
    repo.setUrl(url);

    model.addRepository(repo);

    MavenProject project = new MavenProject(model);

    discovery.discover(settings, project, "blah", true);
  }