コード例 #1
0
  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;
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
  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();
  }
コード例 #5
0
  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);
  }
コード例 #6
0
  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");
  }
コード例 #7
0
 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;
 }
コード例 #8
0
 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;
 }
コード例 #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;
  }
コード例 #10
0
 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;
 }
コード例 #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;
  }
コード例 #12
0
 /**
  * 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();
 }
コード例 #13
0
  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;
  }
コード例 #14
0
 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;
 }
コード例 #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;
  }
コード例 #16
0
 private boolean hasServerSettings() {
   if (serverId == null) {
     return false;
   } else {
     final Server srv = settings.getServer(serverId);
     return srv != null;
   }
 }
コード例 #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;
  }
コード例 #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;
  }
コード例 #19
0
  @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());
  }
コード例 #20
0
  @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);
  }
コード例 #21
0
ファイル: Maven.java プロジェクト: jopecko/airship
  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);
  }
コード例 #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;
  }
コード例 #23
0
 @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);
 }
コード例 #24
0
  @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);
  }
コード例 #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;
  }
コード例 #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;
  }
コード例 #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);
    }
  }
コード例 #28
0
  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;
  }
コード例 #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;
  }
コード例 #30
0
  @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);
  }