Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
semenishchev committed Apr 21, 2022
0 parents commit 4cbb7a4
Show file tree
Hide file tree
Showing 42 changed files with 2,579 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?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>me.mrfunny</groupId>
<artifactId>spigot-packager</artifactId>
<version>1.0-SNAPSHOT</version>
<description>Simple plugin that helps to copy spigot plugin to your server plugins folder when you package project</description>
<name>spigot-packager Package Plugin</name>
<packaging>maven-plugin</packaging>

<url>http://maven.apache.org</url>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<organization>
<name>MrFunny (Koper Studio)</name>
<url>https://koper.pw/</url>
</organization>

<scm>
<url>https://svn.apache.org/viewvc/maven</url>
</scm>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.4</version>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
</execution>
<!-- if you want to generate help goal -->
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>

</project>
39 changes: 39 additions & 0 deletions src/main/java/me/mrfunny/PackagePluginMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package me.mrfunny;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

@Mojo(name = "spigot-package", defaultPhase = LifecyclePhase.COMPILE)
public class PackagePluginMojo extends AbstractMojo {

@Parameter(defaultValue = "${project}", readonly = true, required = true)
MavenProject project;

@Parameter(property = "pluginsFolder", required = true)
String pluginsFolder;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
System.out.println("Copying plugin to " + pluginsFolder);
File outputFile = new File(project.getBuild().getDirectory(), project.getArtifactId() + "-"+ project.getVersion() + ".jar");
File pluginsFile = new File(this.pluginsFolder, project.getArtifactId() + "-"+ project.getVersion() + ".jar");
if (outputFile.exists()) {
try {
Files.copy(outputFile.toPath(), pluginsFile.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
} else {
throw new MojoFailureException("File not found: " + outputFile.getAbsolutePath());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- Generated by maven-plugin-tools 3.6 -->

<plugin>
<name>spigot-packager Package Plugin</name>
<description></description>
<groupId>me.mrfunny</groupId>
<artifactId>spigot-packager</artifactId>
<version>1.0-SNAPSHOT</version>
<goalPrefix>spigot-packager</goalPrefix>
<mojos>
<mojo>
<goal>spigot-package</goal>
<requiresDirectInvocation>false</requiresDirectInvocation>
<requiresProject>true</requiresProject>
<requiresReports>false</requiresReports>
<aggregator>false</aggregator>
<requiresOnline>false</requiresOnline>
<inheritedByDefault>true</inheritedByDefault>
<phase>compile</phase>
<implementation>me.mrfunny.PackagePluginMojo</implementation>
<language>java</language>
<instantiationStrategy>per-lookup</instantiationStrategy>
<executionStrategy>once-per-session</executionStrategy>
<threadSafe>false</threadSafe>
<parameters>
<parameter>
<name>pluginsFolder</name>
<type>java.lang.String</type>
<required>true</required>
<editable>true</editable>
<description></description>
</parameter>
</parameters>
<configuration>
<pluginsFolder implementation="java.lang.String">${pluginsFolder}</pluginsFolder>
</configuration>
</mojo>
</mojos>
</plugin>
Loading

0 comments on commit 4cbb7a4

Please sign in to comment.