org.apache.maven.artifact.DefaultArtifact Java Examples
The following examples show how to use
org.apache.maven.artifact.DefaultArtifact.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DependencyNodeIdRendererTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@Test void versionLessIdWithEmptyClassifier() { // arrange Artifact artifact = new DefaultArtifact( "groupId", "artifactId", "1.0.0", "compile", "type", "", null); // act String result = DependencyNodeIdRenderer.versionlessId().withType(true).render(new DependencyNode(artifact)); // assert assertEquals("groupId:artifactId:type", result); }
Example #2
Source File: ProblemReporterImplTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testMissingParent() throws Exception { TestFileUtils.writeFile(new File(getWorkDir(), "pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" + "<parent><groupId>g</groupId><artifactId>par</artifactId><version>0</version></parent>" + "<artifactId>m</artifactId>" + "</project>"); Project p = ProjectManager.getDefault().findProject(FileUtil.toFileObject(getWorkDir())); assertEquals("g:m:jar:0", p.getLookup().lookup(NbMavenProject.class).getMavenProject().getId()); ProblemReporterImpl pr = getReporter(p); MavenModelProblemsProvider mpp = new MavenModelProblemsProvider(p); Collection<? extends ProjectProblemsProvider.ProjectProblem> problems = mpp.getProblems(); waitForReports(); assertFalse(problems.isEmpty()); assertEquals(Collections.singleton(a2f(new DefaultArtifact("g", "par", "0", null, "pom", null, new DefaultArtifactHandler("pom")))), pr.getMissingArtifactFiles()); }
Example #3
Source File: MavenUtils.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * Checks if an artifact is available in the local repository. The artifact <code>version</code> * must be a specific value, cannot be "LATEST". */ public static boolean isArtifactAvailableLocally(String groupId, String artifactId, String version, String type, String classifier) { try { Preconditions.checkArgument(!MAVEN_LATEST_VERSION.equals(version)); String artifactPath = MavenPlugin.getMaven().getLocalRepository() .pathOf(new DefaultArtifact(groupId, artifactId, version, null /* scope */, type, classifier, new DefaultArtifactHandler(type))); return new File(artifactPath).exists(); } catch (CoreException ex) { logger.log(Level.SEVERE, "Could not lookup local repository", ex); return false; } }
Example #4
Source File: ResolveMojoTest.java From roboconf-platform with Apache License 2.0 | 6 votes |
private RepositorySystem newRepositorySystem() { RepositorySystem repoSystem = new DefaultRepositorySystem() { @Override public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) throws ArtifactResolutionException { ArtifactResult res = new ArtifactResult( request ); Artifact mavenArtifact = ResolveMojoTest.this.artifactIdToArtifact.get( request.getArtifact().getArtifactId()); if( mavenArtifact == null ) throw new ArtifactResolutionException( new ArrayList<ArtifactResult>( 0 ), "Error in test wrapper and settings." ); org.eclipse.aether.artifact.DefaultArtifact art = new org.eclipse.aether.artifact.DefaultArtifact( "groupId", "artifactId", "classifier", "extension", "version", null, mavenArtifact.getFile()); res.setArtifact( art ); return res; } }; return repoSystem; }
Example #5
Source File: MavenUtils.java From mvn-golang with Apache License 2.0 | 6 votes |
/** * Parse string containing artifact record * * @param record string containing record, must not be null * @param handler artifact handler for created artifact, must not be null * @return new created artifact from the record, must not be null * @throws InvalidVersionSpecificationException it will be thrown if version * format is wrong * @throws IllegalArgumentException it will be thrown if record can't be * recognized as artifact record */ @Nonnull public static Artifact parseArtifactRecord( @Nonnull final String record, @Nonnull final ArtifactHandler handler ) throws InvalidVersionSpecificationException { final Matcher matcher = ARTIFACT_RECORD_PATTERN.matcher(record.trim()); if (matcher.find()) { return new DefaultArtifact( matcher.group(1), matcher.group(2), VersionRange.createFromVersion(matcher.group(3)), matcher.group(4).isEmpty() ? null : matcher.group(4), matcher.group(5).isEmpty() ? null : matcher.group(5), matcher.group(6).isEmpty() ? null : matcher.group(6), handler); } throw new IllegalArgumentException("Can't recognize record as artifact: " + record); }
Example #6
Source File: NativeRanlibMojoTest.java From maven-native with MIT License | 6 votes |
public void testMojoLookup() throws Exception { File pluginXml = new File( getBasedir(), "src/test/resources/linker/plugin-config-ranlib.xml" ); NativeRanlibMojo mojo = (NativeRanlibMojo) lookupMojo( "ranlib", pluginXml ); assertNotNull( mojo ); // simulate artifact ArtifactHandler artifactHandler = new DefaultArtifactHandler(); Artifact artifact = new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe", null, artifactHandler ); mojo.getProject().setArtifact( artifact ); mojo.execute(); }
Example #7
Source File: NativeInitializeMojoTest.java From maven-native with MIT License | 6 votes |
public void testMojoLookup() throws Exception { File pluginXml = new File( getBasedir(), "src/test/resources/initialize/plugin-config.xml" ); NativeInitializeMojo mojo = (NativeInitializeMojo) lookupMojo( "initialize", pluginXml ); assertNotNull( mojo ); // simulate artifact ArtifactHandler artifactHandler = new DefaultArtifactHandler(); Artifact artifact = new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe", null, artifactHandler ); mojo.project.setArtifact( artifact ); mojo.setPluginContext( new HashMap<>() ); mojo.execute(); assertEquals( "someArtifactId", mojo.project.getBuild().getFinalName() ); }
Example #8
Source File: AbstractLibertySupport.java From ci.maven with Apache License 2.0 | 6 votes |
private String resolveVersionRange(String groupId, String artifactId, String extension, String version) throws VersionRangeResolutionException { org.eclipse.aether.artifact.Artifact aetherArtifact = new org.eclipse.aether.artifact.DefaultArtifact(groupId, artifactId, extension, version); VersionRangeRequest rangeRequest = new VersionRangeRequest(); rangeRequest.setArtifact(aetherArtifact); rangeRequest.setRepositories(repositories); VersionRangeResult rangeResult = this.repositorySystem.resolveVersionRange(this.repoSession, rangeRequest); if (rangeResult == null || rangeResult.getHighestVersion() == null) { throw new VersionRangeResolutionException(rangeResult, "Unable to resolve version range fram " + groupId + ":" + artifactId + ":" + extension + ":" + version); } getLog().debug("Available versions: " + rangeResult.getVersions()); return rangeResult.getHighestVersion().toString(); }
Example #9
Source File: ArtifactVersionsTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void testSmokes() throws Exception { ArtifactVersion[] versions = versions( "1.0", "3.0", "1.1", "1.0", "1.0.1" ); final DefaultArtifact artifact = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar", "jar", new DefaultArtifactHandler() ); ArtifactVersions instance = new ArtifactVersions( artifact, Arrays.asList( versions ), new MavenVersionComparator() ); assertEquals( "artifact", instance.getArtifactId() ); assertEquals( "group", instance.getGroupId() ); assertArrayEquals( versions( "1.0", "1.0.1", "1.1", "3.0" ), instance.getVersions() ); assertArrayEquals( versions( "3.0" ), instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ) ); assertArrayEquals( versions( "1.1", "3.0" ), instance.getVersions( new DefaultArtifactVersion( "1.0.1" ), null ) ); assertEquals( new DefaultArtifactVersion( "1.1" ), instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ), new DefaultArtifactVersion( "3.0" ) ) ); assertNull( instance.getNewestVersion( new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "3.0" ) ) ); }
Example #10
Source File: GenerateBomMojo.java From sundrio with Apache License 2.0 | 6 votes |
/** * Collects dependencies, including transitives. * Project dependencies retain their scope, while test only dependencies (including transitives) will have test scope. * @param projectDependencies * @return */ private Set<Artifact> getDependencies(final Set<Artifact> projectDependencies) { Set<Artifact> result = new LinkedHashSet<Artifact>(projectDependencies); Set<Artifact> testDependencies = dependenciesWithScope(projectDependencies, Artifact.SCOPE_TEST); Set<Artifact> nonTestDependencies = allBut(projectDependencies, testDependencies); Set<Artifact> testTransitives = resolve(testDependencies); Set<Artifact> nonTestTransitives = resolve(nonTestDependencies); Set<Artifact> testOnlyDependencies = allBut(testTransitives, nonTestTransitives); for (Artifact testOnly : testOnlyDependencies) { result.add(new DefaultArtifact(testOnly.getGroupId(), testOnly.getArtifactId(), testOnly.getVersion(), Artifact.SCOPE_TEST, testOnly.getType(), testOnly.getClassifier(), testOnly .getArtifactHandler())); } result.addAll(resolve(projectDependencies)); return result; }
Example #11
Source File: RawXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 6 votes |
protected void resolveEpisodeArtifacts() throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException { this.episodeArtifacts = new LinkedHashSet<Artifact>(); { final Collection<Artifact> episodeArtifacts = ArtifactUtils.resolve(getArtifactFactory(), getArtifactResolver(), getLocalRepository(), getArtifactMetadataSource(), getEpisodes(), getProject()); this.episodeArtifacts.addAll(episodeArtifacts); } { if (getUseDependenciesAsEpisodes()) { @SuppressWarnings("unchecked") final Collection<Artifact> projectArtifacts = getProject().getArtifacts(); final AndArtifactFilter filter = new AndArtifactFilter(); filter.add(new ScopeArtifactFilter(DefaultArtifact.SCOPE_COMPILE)); filter.add(new TypeArtifactFilter("jar")); for (Artifact artifact : projectArtifacts) { if (filter.include(artifact)) { this.episodeArtifacts.add(artifact); } } } } this.episodeFiles = ArtifactUtils.getFiles(this.episodeArtifacts); }
Example #12
Source File: ExternalBomResolver.java From sundrio with Apache License 2.0 | 6 votes |
private Map<Artifact, Dependency> resolveDependencies(BomImport bom) throws Exception { org.eclipse.aether.artifact.Artifact artifact = new org.eclipse.aether.artifact.DefaultArtifact(bom.getGroupId(), bom.getArtifactId(), "pom", bom.getVersion()); List<RemoteRepository> repositories = remoteRepositories; if (bom.getRepository() != null) { // Include the additional repository into the copy repositories = new LinkedList<RemoteRepository>(repositories); RemoteRepository repo = new RemoteRepository.Builder(bom.getArtifactId() + "-repository", "default", bom.getRepository()).build(); repositories.add(0, repo); } ArtifactRequest artifactRequest = new ArtifactRequest(artifact, repositories, null); system.resolveArtifact(session, artifactRequest); // To get an error when the artifact does not exist ArtifactDescriptorRequest req = new ArtifactDescriptorRequest(artifact, repositories, null); ArtifactDescriptorResult res = system.readArtifactDescriptor(session, req); Map<Artifact, Dependency> mavenDependencies = new LinkedHashMap<Artifact, Dependency>(); if (res.getManagedDependencies() != null) { for (org.eclipse.aether.graph.Dependency dep : res.getManagedDependencies()) { mavenDependencies.put(toMavenArtifact(dep), toMavenDependency(dep)); } } return mavenDependencies; }
Example #13
Source File: AggregatingGraphFactoryTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
private MavenProject createMavenProject(String artifactId) { MavenProject project = new MavenProject(); project.setArtifactId(artifactId); // Make sure that we can modify the list later. project.setCollectedProjects(new ArrayList<>()); DefaultArtifact artifact = new DefaultArtifact("groupId", artifactId, "version", "compile", "jar", "", null); project.setArtifact(artifact); RepositorySystemSession repositorySession = mock(RepositorySystemSession.class); ProjectBuildingRequest projectBuildingRequest = mock(ProjectBuildingRequest.class); when(projectBuildingRequest.getRepositorySession()).thenReturn(repositorySession); //noinspection deprecation project.setProjectBuildingRequest(projectBuildingRequest); return project; }
Example #14
Source File: DependencyNode.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
private static Artifact createMavenArtifact(org.eclipse.aether.graph.DependencyNode dependencyNode) { org.eclipse.aether.artifact.Artifact artifact = dependencyNode.getArtifact(); String scope = null; boolean optional = false; if (dependencyNode.getDependency() != null) { scope = dependencyNode.getDependency().getScope(); optional = dependencyNode.getDependency().isOptional(); } DefaultArtifact mavenArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), scope, artifact.getProperty("type", artifact.getExtension()), artifact.getClassifier(), null ); mavenArtifact.setOptional(optional); return mavenArtifact; }
Example #15
Source File: ForArtifactMojo.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@Override public MavenProject getProject() { ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(this.session.getProjectBuildingRequest()); buildingRequest.setRepositorySession(this.session.getRepositorySession()); buildingRequest.setProject(null); buildingRequest.setResolveDependencies(true); buildingRequest.setActiveProfileIds(this.profiles); DefaultArtifact artifact = new DefaultArtifact(this.groupId, this.artifactId, this.version, SCOPE_COMPILE, this.type, this.classifier, new DefaultArtifactHandler()); try { return this.projectBuilder.build(artifact, buildingRequest).getProject(); } catch (ProjectBuildingException e) { throw new IllegalStateException("Error while creating Maven project from Artifact '" + artifact + "'.", e); } }
Example #16
Source File: DependencyNodeIdRendererTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@Test void versionLessIdWithEmptyScope() { // arrange Artifact artifact = new DefaultArtifact( "groupId", "artifactId", "1.0.0", null, "type", "classifier", null); // act String result = DependencyNodeIdRenderer.versionlessId().withScope(true).render(new DependencyNode(artifact)); // assert assertEquals("groupId:artifactId:compile", result); }
Example #17
Source File: TestPropertiesMojoTest.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
private MojoExecution newMojoExecution(Xpp3Dom... parameters) throws IOException { MojoExecution execution = mojos.newMojoExecution("testProperties", parameters); PluginDescriptor pluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor(); ArtifactHandler handler = new DefaultArtifactHandler("jar"); DefaultArtifact workspaceResolver = new DefaultArtifact("io.takari.m2e.workspace", "org.eclipse.m2e.workspace.cli", "1", Artifact.SCOPE_COMPILE, ".jar", null, handler); workspaceResolver.setFile(new File("target/workspaceResolver.jar").getCanonicalFile()); List<Artifact> pluginArtifacts = new ArrayList<>(pluginDescriptor.getArtifacts()); pluginArtifacts.add(workspaceResolver); pluginDescriptor.setArtifacts(pluginArtifacts); return execution; }
Example #18
Source File: ExampleGraphMojo.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
private static DependencyNode createConflict(Artifact artifact, String winningVersion) { org.eclipse.aether.artifact.DefaultArtifact aetherArtifact = new org.eclipse.aether.artifact.DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), artifact.getVersion()); org.eclipse.aether.artifact.DefaultArtifact winnerArtifact = new org.eclipse.aether.artifact.DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), winningVersion); DefaultDependencyNode dependencyNode = new DefaultDependencyNode(new Dependency(aetherArtifact, artifact.getScope())); dependencyNode.setData(NODE_DATA_WINNER, new DefaultDependencyNode(new Dependency(winnerArtifact, "compile"))); return new DependencyNode(dependencyNode); }
Example #19
Source File: PackageMojo.java From vertx-maven-plugin with Apache License 2.0 | 5 votes |
private void attachIfNeeded(File jar) { if (jar.isFile() && classifier != null && attach) { ArtifactHandler handler = new DefaultArtifactHandler("jar"); Artifact vertxJarArtifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "compile", "jar", classifier, handler); vertxJarArtifact.setFile(jar); this.project.addAttachedArtifact(vertxJarArtifact); } }
Example #20
Source File: ExampleGraphMojo.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
@Override public String createGraph(MavenProject project) { DefaultArtifact aA = new DefaultArtifact("com.example", "artifact-a", "1.0.0", SCOPE_COMPILE, "jar", "", null); DefaultArtifact aB = new DefaultArtifact("com.example", "artifact-b", "1.0.0", SCOPE_COMPILE, "jar", "", null); DefaultArtifact aC = new DefaultArtifact("com.example", "artifact-c", "2.0.0", SCOPE_COMPILE, "jar", "", null); DefaultArtifact aD = new DefaultArtifact("com.example", "artifact-d", "1.0.0", SCOPE_COMPILE, "jar", "", null); DefaultArtifact aE = new DefaultArtifact("com.example.sub", "artifact-e", "1.0.0", SCOPE_PROVIDED, "jar", "", null); DefaultArtifact aF = new DefaultArtifact("com.example.sub", "artifact-f", "1.0.0", SCOPE_RUNTIME, "jar", "", null); DefaultArtifact aG = new DefaultArtifact("com.example.sub", "artifact-g", "1.0.0", SCOPE_TEST, "jar", "", null); DefaultArtifact aZ = new DefaultArtifact("com.example.sub", "artifact-zip", "1.0.0", SCOPE_COMPILE, "zip", "", null); DependencyNode nA = new DependencyNode(aA); DependencyNode nB = new DependencyNode(aB); DependencyNode nC = new DependencyNode(aC); DependencyNode nCDup = createConflict(aC, aC.getVersion()); DependencyNode nCConfl = createConflict(aC, "1.0.0"); DependencyNode nD = new DependencyNode(aD); DependencyNode nE = new DependencyNode(aE); DependencyNode nF = new DependencyNode(aF); DependencyNode nG = new DependencyNode(aG); DependencyNode nZ = new DependencyNode(aZ); addEdge(nA, nB); addEdge(nA, nD); addEdge(nG, nCConfl); addEdge(nB, nC); addEdge(nB, nD); addEdge(nZ, nCDup); addEdge(nD, nE); addEdge(nD, nF); addEdge(nB, nG); addEdge(nB, nZ); return this.graphBuilder.toString(); }
Example #21
Source File: AbstractVertxMojoResolveArtifactTest.java From vertx-maven-plugin with Apache License 2.0 | 5 votes |
private void checkCoordsAgainstSourceArtifact(Artifact mavenArtifact, String coords) { org.eclipse.aether.artifact.DefaultArtifact artifact = new org.eclipse.aether.artifact.DefaultArtifact(coords); assertThat(artifact).extracting( org.eclipse.aether.artifact.DefaultArtifact::getGroupId, org.eclipse.aether.artifact.DefaultArtifact::getArtifactId, org.eclipse.aether.artifact.DefaultArtifact::getVersion, org.eclipse.aether.artifact.DefaultArtifact::getExtension, org.eclipse.aether.artifact.DefaultArtifact::getClassifier ).containsExactly( mavenArtifact.getGroupId(), mavenArtifact.getArtifactId(), mavenArtifact.getVersion(), mavenArtifact.getType(), Objects.toString(mavenArtifact.getClassifier(), "") ); }
Example #22
Source File: DependencyNodeUtil.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
private static DependencyNode createConflict(Artifact artifact, String winningVersion) { org.eclipse.aether.artifact.DefaultArtifact aetherArtifact = new org.eclipse.aether.artifact.DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), artifact.getVersion()); org.eclipse.aether.artifact.DefaultArtifact winnerArtifact = new org.eclipse.aether.artifact.DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), winningVersion); DefaultDependencyNode dependencyNode = new DefaultDependencyNode(new Dependency(aetherArtifact, artifact.getScope())); dependencyNode.setData(NODE_DATA_WINNER, new DefaultDependencyNode(new Dependency(winnerArtifact, "compile"))); return new DependencyNode(dependencyNode); }
Example #23
Source File: ScopeSkipperTest.java From pgpverify-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testConstructCompileRuntimeScopeFilter() { final ScopeSkipper filter = new ScopeSkipper(Artifact.SCOPE_COMPILE_PLUS_RUNTIME); assertFalse(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "system", "jar", "classifier", null))); assertFalse(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "provided", "jar", "classifier", null))); assertFalse(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "compile", "jar", "classifier", null))); assertFalse(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "runtime", "jar", "classifier", null))); assertTrue(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "test", "jar", "classifier", null))); }
Example #24
Source File: ShrinkWrapFatJarPackageServiceTest.java From vertx-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testEmbeddingDependenciesWithAMissingArtifactFile() throws IOException, PackagingException { AbstractVertxMojo mojo = mock(AbstractVertxMojo.class); when(mojo.getLog()).thenReturn(new SystemStreamLog()); Archive archive = new Archive(); archive.setIncludeClasses(false); archive.setDependencySets(ImmutableList.of(new DependencySet())); DefaultArtifact artifact = getSecondArtifact(); artifact.setFile(new File("missing-on-purpose")); Set<Artifact> artifacts = ImmutableSet.of(getFirstArtifact(), artifact); File output = new File(out, "test-all-dependencies-missing-artifact-file.jar"); PackageConfig config = new PackageConfig() .setMojo(mojo) .setOutput(output) .setArtifacts(artifacts) .setArchive(archive); service.doPackage(config); assertThat(output).isFile(); JarFile jar = new JarFile(output); List<String> list = jar.stream().map(ZipEntry::getName) .filter(s -> ! s.endsWith("/")) // Directories .collect(Collectors.toList()); assertThat(list).containsOnly("META-INF/MANIFEST.MF", "testconfig.yaml"); }
Example #25
Source File: An_UpdateChecker.java From deadcode4j with Apache License 2.0 | 5 votes |
private void whenCheckingForUpdate() { PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setPluginArtifact(new DefaultArtifact("de.is24", "junit", "23", null, "maven-plugin", "", null)); MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setPluginDescriptor(pluginDescriptor); result = objectUnderTest.checkForUpdate(new MojoExecution(mojoDescriptor)); }
Example #26
Source File: ShrinkWrapFatJarPackageServiceTest.java From vertx-maven-plugin with Apache License 2.0 | 5 votes |
private DefaultArtifact getFirstArtifact() { JavaArchive jarArchive1 = ShrinkWrap.create(JavaArchive.class); jarArchive1.addAsResource(new File("src/test/resources/testconfig.yaml")); File jar1 = new File(out, "jar1.jar"); jarArchive1.as(ZipExporter.class).exportTo(jar1, true); DefaultArtifact artifact = new DefaultArtifact("org.acme", "jar1", "1.0", "compile", "jar", "", null); artifact.setFile(jar1); return artifact; }
Example #27
Source File: ArtifactVersionsTest.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void test4DigitVersions() throws Exception { ArtifactVersion[] versions = versions( "1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1"); final DefaultArtifact artifact = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar", "jar", new DefaultArtifactHandler() ); // TODO This should also work for the MavenVersionComparator when using maven 3.x libraries ArtifactVersions instance = new ArtifactVersions(artifact, Arrays.asList( versions ), new MercuryVersionComparator() ); assertEquals( "artifact", instance.getArtifactId() ); assertEquals( "group", instance.getGroupId() ); assertThat(instance.getVersions(), Matchers.arrayContaining(versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ))); assertThat(instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ), Matchers.arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1"))); assertThat(instance.getVersions( new DefaultArtifactVersion( "1.0.0.2" ), null ), //Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1"))); Matchers.arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1"))); assertEquals( new DefaultArtifactVersion( "2.121.2.1" ), instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ), new DefaultArtifactVersion( "3.0" ) ) ); assertNull( instance.getNewestVersion( new DefaultArtifactVersion( "1.1.1" ), new DefaultArtifactVersion( "2.0" ) ) ); }
Example #28
Source File: ShrinkWrapFatJarPackageServiceTest.java From vertx-maven-plugin with Apache License 2.0 | 5 votes |
private DefaultArtifact getSecondArtifact() { JavaArchive archive = ShrinkWrap.create(JavaArchive.class); archive.addAsResource(new File("src/test/resources/testconfig2.yaml"), "out/some-config.yaml"); File jar = new File(out, "jar2.jar"); archive.as(ZipExporter.class).exportTo(jar, true); DefaultArtifact artifact = new DefaultArtifact("org.acme", "jar2", "1.0", "compile", "jar", "", null); artifact.setFile(jar); return artifact; }
Example #29
Source File: ProblemReporterImplTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testMissingPlugin() throws Exception { TestFileUtils.writeFile(new File(getWorkDir(), "pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" + "<groupId>g</groupId><artifactId>m</artifactId><version>0</version>" + "<build><plugins><plugin><groupId>g</groupId><artifactId>plug</artifactId><version>0</version><extensions>true</extensions></plugin></plugins></build>" + "</project>"); Project p = ProjectManager.getDefault().findProject(FileUtil.toFileObject(getWorkDir())); ProblemReporterImpl pr = getReporter(p); MavenModelProblemsProvider mpp = new MavenModelProblemsProvider(p); Collection<? extends ProjectProblemsProvider.ProjectProblem> problems = mpp.getProblems(); waitForReports(); assertFalse(problems.isEmpty()); assertEquals(Collections.singleton(a2f(new DefaultArtifact("g", "plug", "0", null, "jar", null, new DefaultArtifactHandler("jar")))), pr.getMissingArtifactFiles()); }
Example #30
Source File: ScopeSkipperTest.java From pgpverify-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testConstructInvalidScopeFilter() { final ScopeSkipper filter = new ScopeSkipper("invalid-scope"); assertTrue(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "system", "jar", "classifier", null))); assertTrue(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "provided", "jar", "classifier", null))); assertTrue(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "compile", "jar", "classifier", null))); assertTrue(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "runtime", "jar", "classifier", null))); assertTrue(filter.shouldSkipArtifact(new DefaultArtifact("a", "b", "1.0", "test", "jar", "classifier", null))); }