Score:-1

settings.xml for maven 3.8.1

cn flag

I switched from Netbeans to Eclipse IDE for Java applications and remote debugging. The Maven project wizard generated a java project with the pom.xml and build.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">
  <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>http://www.example.com</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>https://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 https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-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 https://maven.apache.org/ref/current/maven-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>

Executing the file using ANT build results in this Error

[artifact:mvn] [INFO] Error resolving version for 'org.apache.maven.plugins:maven-resources-plugin': Plugin requires Maven version 3.0

executing

mvn -version Apache Maven 3.6.3

list the current maven version. This version is also linked in the preferences of maven inside the IDE enter image description here

Some research reveals that maven2 is no longer maintained and should not be used. For some reason the folder ./m2 is still in my home drive and used as user settings for the maven build enter image description here

the settings.xml that is apparently used reads

 <settings xmlns="https://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="https://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">
      <localRepository/>
      <interactiveMode/>
      <offline/>
      <pluginGroups/>
      <servers/>
      <mirrors>
        <mirror>
          <id>centralhttps</id>
          <mirrorOf>central</mirrorOf>
          <name>Maven central https</name>
          <url>http://insecure.repo1.maven.org/maven2/</url>
        </mirror>
      </mirrors>
      <proxies/>
      <profiles/>
      <activeProfiles/>
   </settings>

a line linking something to maven2.

How do I change the settings.xml to the current maven version? How does Eclipse changes the settings.xml when maven is upgraded?

When I remove all the plugins no errors are thrown and the .jar is executed on the target. This leads to another question: What do this plugins do when the program works fine without them?

Score:0
br flag

The folder $HOME/.m2 is used for both maven2 and maven3. How confusing? :-) Unless you are doing something special, you can simply remove your settings.xml file.

Although you didn't ask, unless you have a specific need for Eclipse, I recommend IntelliJ community edition. Eclipse has to import the pom.xml into its own configuration. Netbeans and IntelliJ both work with mvn without this step. There is also a special maven plugin for Eclipse that you may want to use if you continue with Eclipse.

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>

That being said, I haven't touched Eclipse for a couple of years...

v3xX avatar
cn flag
where do I integrate this plugin? Directly in the pom.xml
v3xX avatar
cn flag
Adding this plugin leads to another error (Plugin requires Maven version 2.2.1). I have similar errors when buildiung the remote debug configuration with other plugins. I now wasted 2 days on configuration problems which did not occur on Netbeans, VSCode, VisualStudio or Labview. I think I will switch back to Netbeans or have a look at the advertised IntelliJ (the new institute uses Eclipse for some reason)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.