Chks
Chks

Reputation: 23

Maven Errors While Execution

When I execute mvn to copy files to the remote server using Maven.

However I am getting below error message. How can I fix this?

I am following an example as shown in the post https://jarirajari.wordpress.com/2014/06/11/copy-files-and-execute-command-on-a-remote-host-with-maven-antrun-plugin-without-ant-using-ssh-and-scp/

[ERROR] The project [unknown-group-id]:[unknown-artifact-id]:[unknown-version] (D:\projects\sandbox\pom.xml) has 4 errors [ERROR] Malformed POM D:\projects\sandbox\pom.xml: Unrecognised tag: 'plugin' (position: START_TAG seen ...http://maven.apache.org/xsd/maven-4.0.0.xsd"> \r\ n \r\n... @3:9) @ D:\projects\sandbox\pom.xml, line 3, column 9 -> [Help 2] [ERROR] 'groupId' is missing. @ line 1, column 204 [ERROR] 'artifactId' is missing. @ line 1, column 204 [ERROR] 'version' is missing. @ line 1, column 204 [ERROR]

My POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <build>
      <plugin>
         <inherited>false</inherited>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>
         <version>1.6</version>
         <executions>
            <execution>
               <id>test</id>
               <phase>install</phase>
               <goals>
                  <goal>run</goal>
               </goals>
               <configuration>
                  <target name="test">
                     <scp trust="true" failonerror="true" verbose="off" sftp="true" file="" todir="" />
                     <sshexec trust="true" failonerror="true" host="test.server" username="testuser" password="test" command="" timeout="1000" />
                     <taskdef name="scp" classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp">
                        <classpath refid="maven.plugin.classpath" />
                     </taskdef>
                  </target>
               </configuration>
            </execution>
         </executions>
         <dependencies>
            <dependency>
               <groupId>ant</groupId>
               <artifactId>ant-commons-net</artifactId>
               <version>1.6.5</version>
            </dependency>
            <dependency>
               <groupId>org.apache.ant</groupId>
               <artifactId>ant-jsch</artifactId>
               <version>1.9.1</version>
            </dependency>
         </dependencies>
      </plugin>
   </build>
</project>

Any insight is appreciable

Upvotes: 1

Views: 1452

Answers (1)

Robert Scholte
Robert Scholte

Reputation: 12335

You've copied a pom fragment, but put it in the wrong place. A minimal pom looks like this. In your case you need to add at least <build><plugins>-tags around this fragment. When using an IDE you will have good support/code completion or look at the pom structure

Upvotes: 1

Related Questions