Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Maven version reference for build.xml(Unable to build using default wizard)
Maven version reference for build.xml [message #1848401] Wed, 01 December 2021 05:33
Eclipse UserFriend
I recently installed Eclipse (2021-09) IDE on my Ubuntu 20.04. Recently we used Netbeans for most development and remote debugging.

Using the maven project wizard I was able to generate a project with both a build.xml and pom.xml file already generated. I assume the IDE can detect the necessary plugins and configuration. My goal is to connect and debug java applications remotely to a RaspberryPi.

the pom.xml
<?xml version="1.0" encoding="UTF-8"?>

  <modelVersion>4.0.0</modelVersion>

  <groupId>IntelligentHome</groupId>
  <artifactId>RaspberryPi</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>RaspberryPi</name>
  <!-- FIXME change it to the project's website -->
  <url></url>

<!--
	<build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
               <archive>
                  <manifest>
                     <mainClass>IntelligentHome.RaspberryPi.App</mainClass>
                  </manifest>
               </archive>
            </configuration>
         </plugin>
      </plugins>
   </build>
-->

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

<pluginRepositories>
   <pluginRepository> 
    <id>maven2</id> 
    <url>repo.maven.apache.org/maven2/</url> 
  </pluginRepository> 
</pluginRepositories>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle, see core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>


with the build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="hello" default="remote-run" basedir="."
	xmlns:artifact="antlib:org.apache.maven.artifact.ant">

    <!-- Setup RASPBERRY PI properties -->
	<property name="raspberrypi" value="192.168.4.2" />
	<property name="raspberryfolder" value="~" />
	<property name="username" value="pi" />
	<property name="password" value="raspberry" />

	<!--
	<path id="maven-ant-tasks.classpath" path="${ant.libs.dir}/maven-ant-tasks-2.1.3.jar" />
	<typedef 
		resource="org/apache/maven/artifact/ant/antlib.xml"
		uri="antlib:org.apache.maven.artifact.ant"
		classpathref="maven-ant-tasks.classpath" />

    	
	<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
	<typedef 
		resource="org/apache/maven/artifact/ant/antlib.xml" 
		uri="antlib:org.apache.maven.artifact.ant" 
		classpathref="maven-ant-tasks.classpath" />
	-->

    <!-- Add maven install target to be run before deploy -->
    	
	<target name="maven-install"> 
		<artifact:mvn pom="pom.xml"> 
			<arg value="install"/> 
		</artifact:mvn> 
	</target> 

    <!-- Locate the prokect jar and transfer via scp to RASPBERRY PI -->
	<target name="transfer" depends="maven-install">
		<first id="jars">
			<!--
			<fileset dir="target" includes="**/*-SNAPSHOT-jar-with-dependencies.jar" />
			-->
			<fileset dir="target" includes="**/*.jar" />
		</first>
		<pathconvert pathsep="," property="jar.path" refid="jars" />
		<basename file="${jar.path}" property="jar.filename" />
		<echo>">>> Found application ${jar.path}"</echo>

		<echo>">>> Copying application to ${raspberrypi}:${raspberryfolder}/${jar.filename}"</echo>
		<scp 
			localfile="${jar.path}" 
			todir="${username}:${password}@${raspberrypi}:${raspberryfolder}" 
			trust="true" />
	</target>
		
	<!-- Run java -->
	<target name="remote-run" depends="transfer">	
		<echo>">>> Starting ${raspberrypi}:${raspberryfolder}/${jar.filename}"</echo>

		<sshexec 
			host="${raspberrypi}" 
			username="${username}" 
			password="${password}" 
			trust="true" 
			failonerror="true" 
			usepty="true" 
			command="java -jar ${jar.filename}" />
	</target>
	
	<!-- Run java in debug mode and keep waiting for execution -->
	<target name="remote-debug" depends="transfer">	
		<echo>">>> Starting ${raspberrypi}:${raspberryfolder}/${jar.filename} in debug mode"</echo>
		<sshexec 
			host="${raspberrypi}" 
			username="${username}" 
			password="${password}" 
			trust="true" 
			failonerror="true" 
			usepty="true" 
			command="java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=y -jar ${jar.filename}" />
	</target>
</project>


Running the Ant build results in this error
[artifact:mvn] [INFO] Scanning for projects...
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Building RaspberryPi
[artifact:mvn] [INFO]    task-segment: [install]
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [ERROR] BUILD ERROR
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Error resolving version for 'org.apache.maven.plugins:maven-resources-plugin': Plugin requires Maven version 3.0
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] For more information, run Maven with the -e switch
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Total time: < 1 second
[artifact:mvn] [INFO] Finished at: Wed Dec 01 11:15:06 CET 2021
[artifact:mvn] [INFO] Final Memory: 12M/54M
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] Java Result: 1


The current installed maven version is: mvn -version Apache Maven 3.6.3. The workbench also points to the current maven installation (Help -> Preferences -> Maven -> Installation).

What generates this error?

Removing all the plugins from the pom.xml results in no error and the .jar is executed remotely on the target.

Do I need all the plugins? What do they do?
Previous Topic:Content Assist Lag when typing a new object.
Next Topic:Problem with org.eclipse.navigator.navigatorContent
Goto Forum:
  


Current Time: Fri Oct 31 05:18:27 EDT 2025

Powered by FUDForum. Page generated in 0.04231 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top