|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2023 Ben Gilbert and others |
| 3 | + * All rights reserved. This program and the accompanying materials |
| 4 | + * are made available under the terms of the Eclipse Public License 2.0 |
| 5 | + * which accompanies this distribution, and is available at |
| 6 | + * https://www.eclipse.org/legal/epl-2.0/ |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: EPL-2.0 |
| 9 | + *******************************************************************************/ |
| 10 | + |
| 11 | +package org.eclipse.m2e.core; |
| 12 | + |
| 13 | +import java.util.List; |
| 14 | +import java.util.Set; |
| 15 | + |
| 16 | +import org.eclipse.core.resources.IProject; |
| 17 | +import org.eclipse.core.resources.IncrementalProjectBuilder; |
| 18 | +import org.eclipse.core.resources.ResourcesPlugin; |
| 19 | +import org.eclipse.m2e.core.embedder.ArtifactRef; |
| 20 | +import org.eclipse.m2e.core.internal.MavenPluginActivator; |
| 21 | +import org.eclipse.m2e.core.project.IMavenProjectFacade; |
| 22 | +import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase; |
| 23 | +import org.junit.After; |
| 24 | +import org.junit.Assert; |
| 25 | +import org.junit.Test; |
| 26 | + |
| 27 | +public class MavenDependencyTest extends AbstractMavenProjectTestCase { |
| 28 | + |
| 29 | + @After |
| 30 | + public void clearWorkspace() throws Exception { |
| 31 | + for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { |
| 32 | + p.delete(true, null); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testArtifactsIncludeClassifier() throws Exception { |
| 38 | + IProject project = importProject("resources/projects/classifier/pom.xml"); |
| 39 | + project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); |
| 40 | + waitForJobsToComplete(monitor); |
| 41 | + |
| 42 | + IMavenProjectFacade facade = MavenPluginActivator.getDefault().getMavenProjectManagerImpl().create(project, monitor); |
| 43 | + Assert.assertNotNull(facade); |
| 44 | + |
| 45 | + Set<ArtifactRef> artifacts = facade.getMavenProjectArtifacts(); |
| 46 | + Assert.assertNotNull(artifacts); |
| 47 | + |
| 48 | + List<String> portableRefs = artifacts.stream() |
| 49 | + .map(ref -> ref.artifactKey().toPortableString()) |
| 50 | + .toList(); |
| 51 | + // Confirm two different artifacts |
| 52 | + Assert.assertEquals("com.example:dependency-1:0.0.1-SNAPSHOT::", portableRefs.get(0)); |
| 53 | + Assert.assertEquals("com.example:dependency-1:0.0.1-SNAPSHOT:classifier:", portableRefs.get(1)); |
| 54 | + } |
| 55 | + |
| 56 | +} |
0 commit comments