@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 static MavenProject createProject(String artifactId, String version, File file) { Model model = new Model(); model.setGroupId("groupId"); model.setArtifactId(artifactId); model.setVersion(version); MavenProject project = new MavenProject(model); project.setFile(file); return project; }
@Command("set-artifactid") public void setArtifactId( final PipeOut out, @Option(description = "the new artifactId; for example: \"forge-shell\"") final String artifactId) { Assert.notNull(artifactId, "GroupId must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setArtifactId(artifactId); mvn.setPOM(pom); out.println("Set artifactId [ " + artifactId + " ]"); }
private MavenProject buildProjectStub(final Artifact depArtifact) { final Model model = new Model(); model.setGroupId(depArtifact.getGroupId()); model.setArtifactId(depArtifact.getArtifactId()); model.setVersion(depArtifact.getBaseVersion()); model.setPackaging(depArtifact.getType()); model.setDescription("Stub for " + depArtifact.getId()); final MavenProject project = new MavenProject(model); project.setArtifact(depArtifact); return project; }
@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); }
@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); }
protected void setAttributes(Model model) { if (this.getGroupId() != null) { model.setGroupId(this.getGroupId()); } if (this.getArtifactId() != null) { model.setArtifactId(this.getArtifactId()); } if (this.getVersion() != null) { model.setVersion(this.getVersion()); } if (this.getPackaging() != null) { model.setPackaging(this.getPackaging()); } if (this.getName() != null) { model.setName(this.getName()); } if (this.getDesc() != null) { model.setDescription(this.getDesc()); } }
public void importProjects( IProgressMonitor monitor, File pomFile, String projectName, String groupId, String artifactId, String version) throws CoreException { IProjectConfigurationManager manager = MavenPlugin.getProjectConfigurationManager(); ProjectImportConfiguration config = new ProjectImportConfiguration(); Collection<MavenProjectInfo> infos = new ArrayList<MavenProjectInfo>(); Model model = new Model(); model.setGroupId(groupId); model.setArtifactId(artifactId); model.setVersion(version); model.setPomFile(pomFile); MavenProjectInfo info = new MavenProjectInfo(projectName, pomFile, model, null); infos.add(info); manager.importProjects(infos, config, monitor); }
@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); }
public Model toMavenModel() { Model model = new Model(); model.setBuild(new Build()); model.setDescription(description); model.setUrl(url); model.setName(projectId.getArtifact()); model.setGroupId(projectId.getGroup()); model.setVersion(projectId.getVersion()); model.setArtifactId(projectId.getArtifact()); model.setModelVersion("4.0.0"); // parent if (parent != null) { model.setParent(parent); } model.setPackaging(packaging); if (properties != null) { Properties modelProperties = new Properties(); for (Property p : properties) { modelProperties.setProperty(p.getKey(), p.getValue()); } model.setProperties(modelProperties); } // Add jar repository urls. if (null != repositories) { for (String repoUrl : repositories.getRepositories()) { Repository repository = new Repository(); repository.setId(Integer.toString(repoUrl.hashCode())); repository.setUrl(repoUrl); model.addRepository(repository); } } // Add dependency management if (overrides != null) { DependencyManagement depMan = new DependencyManagement(); for (Id dep : overrides) { Dependency dependency = new Dependency(); dependency.setGroupId(dep.getGroup()); dependency.setArtifactId(dep.getArtifact()); dependency.setVersion(dep.getVersion()); // JVZ: We need to parse these dependency.setType("jar"); if (null != dep.getClassifier()) { dependency.setClassifier(dep.getClassifier()); } depMan.addDependency(dependency); } model.setDependencyManagement(depMan); } // Add project dependencies. if (deps != null) { for (Id dep : deps) { Dependency dependency = new Dependency(); dependency.setGroupId(dep.getGroup()); dependency.setArtifactId(dep.getArtifact()); dependency.setVersion(dep.getVersion()); // JVZ: We need to parse these dependency.setType("jar"); if (null != dep.getClassifier()) { dependency.setClassifier(dep.getClassifier()); } model.addDependency(dependency); } } if (modules != null) { model.setModules(modules); } if (pluginOverrides != null) { PluginManagement management = new PluginManagement(); management.setPlugins(pluginOverrides); model.getBuild().setPluginManagement(management); } if (plugins != null) { model.getBuild().setPlugins(plugins); } // Optional source dirs customization. if (dirs != null) { Build build = new Build(); String srcDir = dirs.get("src"); String testDir = dirs.get("test"); if (null != srcDir) build.setSourceDirectory(srcDir); if (null != testDir) build.setTestSourceDirectory(testDir); model.setBuild(build); } if (null != scm) { Scm scm = new Scm(); scm.setConnection(this.scm.getConnection()); scm.setDeveloperConnection(this.scm.getDeveloperConnection()); scm.setUrl(this.scm.getUrl()); model.setScm(scm); } return model; }