From 390e610c65ef0ec2ec0e4851d7e1eaf53e7787f3 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 12 Jan 2024 21:03:02 +0100 Subject: [PATCH] [MDEPLOY-313] Update to parent 41, cleanup (#47) In general perform a cleanup of plugin, apply updates where needed. The plugin now builds against 3.9.x latest, and minimum is left as is (3.2.5). A notable change along that above is removal of "baked in" packaging, now plugin relies completely and only on what project and artifact tells, there is no "if this is POM" check anymore. The new "BOM UT" shows this in action. Has to be noted though, that the UT tests ONLY the plugin, to use BOM packaging you need Maven that knows what it is (Maven 3 w/ extension or Maven 4 that has it OOTB). --- https://issues.apache.org/jira/browse/MDEPLOY-313 --- pom.xml | 72 +++++--- .../verify.groovy | 4 +- .../maven/plugins/deploy/DeployFileMojo.java | 27 +-- .../maven/plugins/deploy/DeployMojo.java | 32 +++- .../plugins/deploy/DeployFileMojoTest.java | 16 +- .../maven/plugins/deploy/DeployMojoTest.java | 166 ++++++++++-------- .../deploy/stubs/DeployBomArtifactStub.java | 37 ++++ .../deploy/stubs/DeployPomArtifactStub.java | 37 ++++ .../unit/basic-deploy-bom/plugin-config.xml | 39 ++++ .../target/deploy-test-file-1.0-SNAPSHOT.pom | 28 +++ .../unit/basic-deploy-pom/plugin-config.xml | 2 +- 11 files changed, 321 insertions(+), 139 deletions(-) create mode 100644 src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java create mode 100644 src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java create mode 100644 src/test/resources/unit/basic-deploy-bom/plugin-config.xml create mode 100644 src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom diff --git a/pom.xml b/pom.xml index fc75b7c3..0340c384 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 39 + 41 @@ -43,7 +43,7 @@ under the License. - ${mavenVersion} + 3.2.5 @@ -69,24 +69,24 @@ under the License. 8 - 3.2.5 + 3.9.6 - 1.7.5 + 1.7.36 - 1.0.0.v20140518 + 1.9.18 - 3.1.0 - 3.10.1 - 3.1.0 - 3.1.0 - 3.3.0 - 3.4.1 - ${maven.plugin.tools.version} - 3.3.0 - 3.2.1 - ${surefire.version} - 3.3.2 + ${version.maven-antrun-plugin} + ${version.maven-compiler-plugin} + ${version.maven-enforcer-plugin} + ${version.maven-install-plugin} + ${version.maven-jar-plugin} + ${version.maven-javadoc-plugin} + ${version.maven-plugin-tools} + ${version.maven-resources-plugin} + ${version.maven-source-plugin} + ${version.maven-surefire} + ${version.maven-war-plugin} 2023-03-21T14:38:01Z @@ -128,14 +128,18 @@ under the License. plexus-utils - org.eclipse.aether - aether-api + org.codehaus.plexus + plexus-xml + + + org.apache.maven.resolver + maven-resolver-api ${resolverVersion} provided - org.eclipse.aether - aether-util + org.apache.maven.resolver + maven-resolver-util ${resolverVersion} compile @@ -164,25 +168,25 @@ under the License. org.apache.maven - maven-aether-provider + maven-resolver-provider ${mavenVersion} test - org.eclipse.aether - aether-connector-basic + org.apache.maven.resolver + maven-resolver-connector-basic ${resolverVersion} test - org.eclipse.aether - aether-transport-file + org.apache.maven.resolver + maven-resolver-transport-file ${resolverVersion} test - org.eclipse.aether - aether-transport-http + org.apache.maven.resolver + maven-resolver-transport-http ${resolverVersion} test @@ -204,9 +208,21 @@ under the License. ${slf4jVersion} test - + + + + org.apache.maven.plugins + maven-compiler-plugin + + none + true + + + + + run-its diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy index 2b197b2d..181104aa 100644 --- a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy @@ -25,5 +25,5 @@ File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() assert buildLog.text.contains( "[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/mdeploy178/pom.xml as pomFile" ) -def pomProject = new XmlSlurper().parse( deployedPom ) -assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( pomProject.url.text() ) \ No newline at end of file +def pomProject = new groovy.xml.XmlParser().parse( deployedPom ) +assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( pomProject.get("url").text() ) \ No newline at end of file diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java index aeaf5f77..7e6536f1 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -43,9 +43,9 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.WriterFactory; +import org.codehaus.plexus.util.xml.ReaderFactory; +import org.codehaus.plexus.util.xml.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; @@ -429,21 +429,14 @@ private void processModel(Model model) { * @throws MojoExecutionException If the file doesn't exist or cannot be read. */ Model readModel(File pomFile) throws MojoExecutionException { - Reader reader = null; - try { - reader = ReaderFactory.newXmlReader(pomFile); - final Model model = new MavenXpp3Reader().read(reader); - reader.close(); - reader = null; - return model; + try (Reader reader = ReaderFactory.newXmlReader(pomFile)) { + return new MavenXpp3Reader().read(reader); } catch (FileNotFoundException e) { throw new MojoExecutionException("POM not found " + pomFile, e); } catch (IOException e) { throw new MojoExecutionException("Error reading POM " + pomFile, e); } catch (XmlPullParserException e) { throw new MojoExecutionException("Error parsing POM " + pomFile, e); - } finally { - IOUtil.close(reader); } } @@ -456,23 +449,17 @@ Model readModel(File pomFile) throws MojoExecutionException { private File generatePomFile() throws MojoExecutionException { Model model = generateModel(); - Writer fw = null; try { File tempFile = File.createTempFile("mvndeploy", ".pom"); tempFile.deleteOnExit(); - fw = WriterFactory.newXmlWriter(tempFile); - - new MavenXpp3Writer().write(fw, model); - - fw.close(); - fw = null; + try (Writer fw = WriterFactory.newXmlWriter(tempFile)) { + new MavenXpp3Writer().write(fw, model); + } return tempFile; } catch (IOException e) { throw new MojoExecutionException("Error writing temporary pom file: " + e.getMessage(), e); - } finally { - IOUtil.close(fw); } } diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java index c9b0d4a4..c3ea850a 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -38,8 +38,10 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifact; +import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.deployment.DeployRequest; import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.artifact.ArtifactIdUtils; /** * Deploys an artifact to remote repository. @@ -285,17 +287,35 @@ private boolean hasExecution(Plugin plugin) { } private void processProject(final MavenProject project, DeployRequest request) throws MojoExecutionException { + // always exists, as project exists + Artifact pomArtifact = RepositoryUtils.toArtifact(new ProjectArtifact(project)); + // always exists, but at "init" is w/o file (packaging plugin assigns file to this when packaged) + Artifact projectArtifact = RepositoryUtils.toArtifact(project.getArtifact()); + + // pom project: pomArtifact and projectArtifact are SAME + // jar project: pomArtifact and projectArtifact are DIFFERENT + // incomplete project: is not pom project and projectArtifact has no file + + // we must compare coordinates ONLY (as projectArtifact may not have file, and Artifact.equals factors it in) + // BUT if projectArtifact has file set, use that one + if (ArtifactIdUtils.equalsId(pomArtifact, projectArtifact)) { + if (isFile(projectArtifact.getFile())) { + pomArtifact = projectArtifact; + } + projectArtifact = null; + } - if (isFile(project.getFile())) { - request.addArtifact(RepositoryUtils.toArtifact(new ProjectArtifact(project))); + if (isFile(pomArtifact.getFile())) { + request.addArtifact(pomArtifact); } else { throw new MojoExecutionException("The project POM could not be attached"); } - if (!"pom".equals(project.getPackaging())) { - org.apache.maven.artifact.Artifact mavenMainArtifact = project.getArtifact(); - if (isFile(mavenMainArtifact.getFile())) { - request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact)); + // is not packaged, is "incomplete" + boolean isIncomplete = projectArtifact != null && !isFile(projectArtifact.getFile()); + if (projectArtifact != null) { + if (!isIncomplete) { + request.addArtifact(projectArtifact); } else if (!project.getAttachedArtifacts().isEmpty()) { if (allowIncompleteProjects) { getLog().warn(""); diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java index f36e6892..572d8e48 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -28,6 +28,7 @@ import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.ProjectBuildingRequest; import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.DefaultLocalPathComposer; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import org.mockito.InjectMocks; @@ -86,8 +87,9 @@ public void testBasicDeployFile() throws Exception { when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -194,8 +196,9 @@ public void testDeployIfClassifierIsSet() throws Exception { when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -248,8 +251,9 @@ public void testDeployIfArtifactIsNotJar() throws Exception { when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java index c43bdf5c..3b0df77e 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.execution.MavenSession; @@ -37,11 +36,10 @@ import org.apache.maven.project.ProjectBuildingRequest; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.internal.impl.DefaultLocalPathComposer; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; -import org.junit.Ignore; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; @@ -75,10 +73,11 @@ public void setUp() throws Exception { session = mock(MavenSession.class); when(session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) - .thenReturn(new ConcurrentHashMap()); + .thenReturn(new ConcurrentHashMap<>()); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(session.getRepositorySession()).thenReturn(repositorySession); remoteRepo = new File(REMOTE_REPO); @@ -124,8 +123,9 @@ public void testBasicDeploy() throws Exception { ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -300,8 +300,9 @@ public void testBasicDeployWithPackagingAsPom() throws Exception { ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -363,6 +364,82 @@ public void testBasicDeployWithPackagingAsPom() throws Exception { assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } + public void testBasicDeployWithPackagingAsBom() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-bom/plugin-config.xml"); + + mojo = (DeployMojo) lookupMojo("deploy", testPom); + + MockitoAnnotations.initMocks(this); + + assertNotNull(mojo); + + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); + + File pomFile = new File( + getBasedir(), + "target/test-classes/unit/basic-deploy-bom/target/" + "deploy-test-file-1.0-SNAPSHOT.pom"); + + assertTrue(pomFile.exists()); + + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); + project.setGroupId("org.apache.maven.test"); + project.setArtifactId("maven-deploy-test"); + project.setVersion("1.0-SNAPSHOT"); + + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); + + artifact = (DeployArtifactStub) project.getArtifact(); + + artifact.setArtifactHandlerExtension(project.getPackaging()); + + artifact.setFile(pomFile); + + ArtifactRepositoryStub repo = getRepoStub(mojo); + + repo.setAppendToUrl("basic-deploy-bom"); + + mojo.execute(); + + List expectedFiles = new ArrayList<>(); + List fileList = new ArrayList<>(); + + expectedFiles.add("org"); + expectedFiles.add("apache"); + expectedFiles.add("maven"); + expectedFiles.add("test"); + expectedFiles.add("maven-deploy-test"); + expectedFiles.add("1.0-SNAPSHOT"); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.sha1"); + // as we are in SNAPSHOT the file is here twice + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + remoteRepo = new File(remoteRepo, "basic-deploy-bom"); + + File[] files = remoteRepo.listFiles(); + + for (File file : Objects.requireNonNull(files)) { + addFileToList(file, fileList); + } + + assertEquals(expectedFiles.size(), fileList.size()); + + assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); + } + public void testDeployIfArtifactFileIsNull() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml"); @@ -413,8 +490,9 @@ public void testDeployWithAttachedArtifacts() throws Exception { ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -490,70 +568,6 @@ public void testDeployWithAttachedArtifacts() throws Exception { assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } - @Ignore("SCP is not part of Maven3 distribution. Aether handles transport extensions.") - public void _testBasicDeployWithScpAsProtocol() throws Exception { - String originalUserHome = System.getProperty("user.home"); - - // FIX THE DAMN user.home BEFORE YOU DELETE IT!!! - File altHome = new File(getBasedir(), "target/ssh-user-home"); - altHome.mkdirs(); - - System.out.println("Testing user.home value for .ssh dir: " + altHome.getCanonicalPath()); - - Properties props = System.getProperties(); - props.setProperty("user.home", altHome.getCanonicalPath()); - - System.setProperties(props); - - File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-scp/plugin-config.xml"); - - mojo = (DeployMojo) lookupMojo("deploy", testPom); - - assertNotNull(mojo); - - RepositorySystem repositorySystem = mock(RepositorySystem.class); - - setVariableValueToObject(mojo, "repositorySystem", repositorySystem); - - File file = new File( - getBasedir(), - "target/test-classes/unit/basic-deploy-scp/target/" + "deploy-test-file-1.0-SNAPSHOT.jar"); - - assertTrue(file.exists()); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); - - artifact = (DeployArtifactStub) project.getArtifact(); - - artifact.setFile(file); - - String altUserHome = System.getProperty("user.home"); - - if (altUserHome.equals(originalUserHome)) { - // this is *very* bad! - throw new IllegalStateException( - "Setting 'user.home' system property to alternate value did NOT work. Aborting test."); - } - - File sshFile = new File(altUserHome, ".ssh"); - - System.out.println("Testing .ssh dir: " + sshFile.getCanonicalPath()); - - // delete first the .ssh folder if existing before executing the mojo - if (sshFile.exists()) { - FileUtils.deleteDirectory(sshFile); - } - - mojo.execute(); - - assertTrue(sshFile.exists()); - - FileUtils.deleteDirectory(sshFile); - } - public void testLegacyAltDeploymentRepositoryWithDefaultLayout() throws Exception { DeployMojo mojo = new DeployMojo(); diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java new file mode 100644 index 00000000..b5c55a37 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.deploy.stubs; + +import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; + +public class DeployBomArtifactStub extends DeployArtifactStub { + @Override + public String getType() { + return "bom"; + } + + public ArtifactHandler getArtifactHandler() { + return new DefaultArtifactHandler() { + public String getExtension() { + return "pom"; + } + }; + } +} diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java new file mode 100644 index 00000000..238bb286 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.deploy.stubs; + +import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; + +public class DeployPomArtifactStub extends DeployArtifactStub { + @Override + public String getType() { + return "pom"; + } + + public ArtifactHandler getArtifactHandler() { + return new DefaultArtifactHandler() { + public String getExtension() { + return "pom"; + } + }; + } +} diff --git a/src/test/resources/unit/basic-deploy-bom/plugin-config.xml b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml new file mode 100644 index 00000000..53bb8866 --- /dev/null +++ b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml @@ -0,0 +1,39 @@ + + + + + + + maven-deploy-plugin + + + ${basedir}/src/test/resources/unit/basic-deploy-bom/plugin-config.xml + bom + + + + ${basedir} + + + + + + + diff --git a/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom b/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom new file mode 100644 index 00000000..9c7bc402 --- /dev/null +++ b/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom @@ -0,0 +1,28 @@ + + + + + 4.0.0 + org.apache.maven.test + maven-deploy-file-test + 1.0 + bom + + \ No newline at end of file diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml index 8cf373c8..27d5f259 100644 --- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml @@ -26,7 +26,7 @@ under the License. ${basedir}/src/test/resources/unit/basic-deploy-pom/plugin-config.xml pom - + ${basedir}