0

I have the following code.

I am trying to create a 'pom.xml' file for a bukkit plugin (Minecraft) using Maven.

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.3.2</version>
                 <executions>
                     <execution>
                            <goals>
                                  <goal>test</goal>
                            </goals>
                     </execution>
                 </executions>

This gave me the error:

No goals have been specified for this build. You must specify a valid lifecycle phase or a goal

I thus amended the code by adding 3 lines below 'executions', to set a goal which I specified as being 'test', given that I want to run the code and see if I get any errors (i.e., if it works).

However, this gives me the error: 'invalid goal for this plugin: test'.

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.3.2</version>
                 <executions>
                     <execution>
                            <goals>
                                  <goal>test</goal>
                            </goals>
                     </execution>
                 </executions>

I would be so grateful for a helping hand!

Caledonian26
  • 727
  • 1
  • 10
  • 27
  • The message is comming from calling Maven via command line and dont give something alike `mvn clean` or `mvn package` it is not intendet to define a `..` via execution for the maven-compiler-plugin ... apart from that the version is a very old version of maven-compiler-plugin (better use a more recent version)... – khmarbaise Nov 22 '22 at 19:38
  • Thank you! :) I have updated the version to 3.8.6 - am still troubleshooting - I now have the issue: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.8.6 or one of its dependencies could not be resolved :) – Caledonian26 Nov 22 '22 at 20:30
  • 1
    Probably because there is no such version: https://search.maven.org/artifact/org.apache.maven.plugins/maven-compiler-plugin . The plug-in version numbers do not always coincide with the Maven version numbers. – nitind Nov 22 '22 at 21:10
  • @Caledonian26 Have you tried to call Maven via `mvn package` on plain command line? – khmarbaise Nov 23 '22 at 07:06
  • @khmarbaise I didn't try that! However, I've now managed to solve my issue - thank you so much for your help :) – Caledonian26 Nov 23 '22 at 09:23

1 Answers1

0

I changed the version to 3.10.1 and the target to 17 as follows, and the code successfully ran:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.10.1</version>       
              <configuration>
                  <source>17</source>
                  <target>17</target>
              </configuration>   
        </plugin>
      </plugins>
    </pluginManagement>
</build>
   <repositories>
       <repository>
         <id>spigot-repo</id>
         <url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
       </repository>
   </repositories>
      <dependencies>
       <dependency>
           <groupId>org.spigotmc</groupId>
           <artifactId>spigot-api</artifactId>
           <version>1.16.5-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
           <type>jar</type>
           <scope>provided</scope>
       </dependency>
   </dependencies>
</project>

Thanks so much for all your help!

Caledonian26
  • 727
  • 1
  • 10
  • 27