Home > Net >  Convert Maven project to Jar file to use as minecraft plugin
Convert Maven project to Jar file to use as minecraft plugin

Time:11-26

I am trying to convert a Maven project (with source code created using a Bukkit/Spigot API and the Java programming language) to a .jar file on eclipse (to then add as a plugin to my minecraft server).

I have selected 'run as' when clicking on the project name, and then I selected 'maven build' (screenshot 1).

I then typed in 'package' in the 'goal' box (screenshot 2).

However, although it runs successfully (with no errors)(screenshot 3), there is no .jar file appearing in the 'target' folder.

I would be so grateful for a helping hand!

Screenshot 1:

enter image description here

Screenshot 2:

enter image description here

Screenshot 3:

enter image description here

CodePudding user response:

If you run in terminal:

mvn package

This should create jar file under target folder.

CodePudding user response:

I solved this issue by amending the pom.xml code to as follows:

 <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>
                  <release>17</release>
              </configuration>   
        </plugin>
      </plugins>
    </pluginManagement>
</build>
   <repositories>
       <repository>
          <id>papermc</id>
          <url>https://repo.papermc.io/repository/maven-public/</url>
       </repository>
   </repositories>
    <dependencies>
       <dependency>
          <groupId>io.papermc.paper</groupId>
          <artifactId>paper-api</artifactId>
          <version>1.19.2-R0.1-SNAPSHOT</version>
          <scope>provided</scope>
       </dependency>
   </dependencies>
</project>

I then set the current directory on the terminal on my mac to the path to the project on maven.

cd /Users/macbook/eclipse-workspace/newestplugin

I then entered: 'mvn clean package' into the terminal on eclipse and it worked.

'mvn clean package'

A .jar file was created in the 'target' folder on eclipse (under my project).

  • Related