Reapplied commit to improve Maven.

Fixed test class failure.
This commit is contained in:
tastybento 2018-08-03 19:10:09 -07:00
parent 7aa2f33eab
commit bad870d3da
13 changed files with 261 additions and 234 deletions

View File

@ -1,23 +1,19 @@
language: java language: java
sudo: false sudo: false
install: true
before_install:
- sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g'
~/.m2/settings.xml
addons: addons:
sonarcloud: sonarcloud:
organization: "tastybento-github" organization: "tastybento-github"
token: token:
secure: $SONAR_TOKEN secure: $SONAR_TOKEN
branches: branches:
- develop - develop
- master - master
jdk: jdk:
- oraclejdk8 - oraclejdk8
script: script:
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar - mvn clean package -P sonar -B
- echo "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" - echo "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
cache: cache:
directories: directories:
- '$HOME/.m2/repository' - '$HOME/.m2/repository'
- '$HOME/.sonar/cache' - '$HOME/.sonar/cache'

View File

@ -1,7 +1,7 @@
BentoBox BentoBox
======== ========
[![Build Status](https://travis-ci.org/tastybento/bskyblock.svg?branch=master)](https://travis-ci.org/tastybento/bskyblock) [![Build Status](https://ci.codemc.org/buildStatus/icon?job=BentoBoxWorld/bentobox)](https://ci.codemc.org/job/BentoBoxWorld/job/bentobox/)
![Lines Of Code](https://sonarcloud.io/api/project_badges/measure?project=world.bentobox%3Abentobox%3Adevelop&metric=ncloc) ![Lines Of Code](https://sonarcloud.io/api/project_badges/measure?project=world.bentobox%3Abentobox%3Adevelop&metric=ncloc)
![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=world.bentobox%3Abentobox%3Adevelop&metric=sqale_rating) ![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=world.bentobox%3Abentobox%3Adevelop&metric=sqale_rating)
![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=world.bentobox%3Abentobox%3Adevelop&metric=reliability_rating) ![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=world.bentobox%3Abentobox%3Adevelop&metric=reliability_rating)
@ -32,7 +32,7 @@ This is an actively developed project but we are not currently accepting Pull Re
Development Builds Development Builds
================== ==================
Jenkins: https://ci.codemc.org/job/Tastybento/job/bskyblock/ Jenkins: https://ci.codemc.org/job/BentoBoxWorld/job/bentobox/
API API
=== ===
@ -47,12 +47,12 @@ Maven dependency:
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>us.tastybento</groupId> <groupId>world.bentobox</groupId>
<artifactId>bskyblock</artifactId> <artifactId>bentobox</artifactId>
<version>FC-0.74</version> <version>0.8.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
``` ```
You can find the javadoc here: https://ci.codemc.org/job/Tastybento/job/bskyblock/javadoc/ You can find the javadoc here: https://ci.codemc.org/job/BentoBoxWorld/job/bentobox/javadoc/

433
pom.xml
View File

@ -1,205 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId> <groupId>world.bentobox</groupId>
<packaging>jar</packaging> <artifactId>bentobox</artifactId>
<name>BentoBox</name> <version>0.9.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source> <name>BentoBox</name>
<maven.compiler.target>1.8</maven.compiler.target> <description>BentoBox is an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland.</description>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <url>https://github.com/BentoBoxWorld/bentobox</url>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <inceptionYear>2018</inceptionYear>
<powermock.version>1.7.4</powermock.version>
</properties> <scm>
<build> <connection>scm:git:https://github.com/BentoBoxWorld/bentobox.git</connection>
<defaultGoal>clean package install</defaultGoal> <developerConnection>scm:git:git@github.com:BentoBoxWorld/bentobox.git</developerConnection>
<resources> <url>https://github.com/BentoBoxWorld/bentobox</url>
<resource> </scm>
<targetPath>.</targetPath>
<filtering>true</filtering> <ciManagement>
<directory>${basedir}</directory> <system>jenkins</system>
<includes> <url>http://ci.codemc.org/job/BentoBoxWorld/job/bentobox</url>
<include>*.yml</include> </ciManagement>
</includes>
</resource> <issueManagement>
<resource> <system>GitHub</system>
<targetPath>schems</targetPath> <url>https://github.com/BentoBoxWorld/bentobox/issues</url>
<filtering>false</filtering> </issueManagement>
<directory>${basedir}/schems</directory>
<includes> <distributionManagement>
<include>*.schem</include> <snapshotRepository>
</includes> <id>codemc-snapshots</id>
</resource> <url>https://repo.codemc.org/repository/maven-snapshots</url>
<resource> </snapshotRepository>
<targetPath>locales</targetPath> <repository>
<filtering>false</filtering> <id>codemc-releases</id>
<directory>${basedir}/locales</directory> <url>https://repo.codemc.org/repository/maven-releases</url>
<includes> </repository>
<include>*.yml</include> </distributionManagement>
</includes>
</resource> <properties>
</resources> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugins> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<plugin> <java.version>1.8</java.version>
<groupId>org.apache.maven.plugins</groupId> <powermock.version>1.7.4</powermock.version>
<artifactId>maven-resources-plugin</artifactId> </properties>
<version>3.0.2</version>
<configuration> <repositories>
<nonFilteredFileExtensions> <repository>
<nonFilteredFileExtension>schematic</nonFilteredFileExtension> <id>spigot-repo</id>
</nonFilteredFileExtensions> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</configuration> </repository>
</plugin> </repositories>
<plugin>
<artifactId>maven-compiler-plugin</artifactId> <dependencies>
<version>3.5</version> <dependency>
<configuration> <groupId>org.spigotmc</groupId>
<source>1.8</source> <artifactId>spigot-api</artifactId>
<target>1.8</target> <version>1.13-R0.1-SNAPSHOT</version>
</configuration> <scope>provided</scope>
</plugin> </dependency>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <dependency>
<version>1.6</version> <executions> <execution> <phase>package</phase> <goals> <groupId>org.mockito</groupId>
<goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <artifactId>mockito-all</artifactId>
<mainClass>world.bentobox.bentobox.BSkyBlock</mainClass> </transformer> </transformers> <version>1.10.19</version>
</configuration> </execution> </executions> </plugin> --> <scope>test</scope>
</dependency>
<plugin> <dependency>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.powermock</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>powermock-module-junit4</artifactId>
<version>3.0.1</version> <version>${powermock.version}</version>
<executions> <scope>test</scope>
<execution> </dependency>
<id>attach-sources</id> <dependency>
<goals> <groupId>org.powermock</groupId>
<goal>jar-no-fork</goal> <artifactId>powermock-api-mockito</artifactId>
</goals> <version>${powermock.version}</version>
</execution> <scope>test</scope>
</executions> </dependency>
</plugin> <dependency>
<plugin> <groupId>org.mongodb</groupId>
<groupId>org.apache.maven.plugins</groupId> <artifactId>mongodb-driver</artifactId>
<artifactId>maven-javadoc-plugin</artifactId> <version>3.8.0</version>
<version>3.0.0</version> </dependency>
<configuration> </dependencies>
<additionalJOption>-Xdoclint:none</additionalJOption>
</configuration> <build>
<executions> <defaultGoal>clean package</defaultGoal>
<execution> <resources>
<id>attach-javadocs</id> <resource>
<goals> <directory>src/main/resources</directory>
<goal>jar</goal> <filtering>true</filtering>
</goals> </resource>
</execution> <resource>
</executions> <directory>src/main/resources/locales</directory>
</plugin> <targetPath>./locales</targetPath>
</plugins> <filtering>false</filtering>
<pluginManagement> </resource>
<plugins> </resources>
<plugin> <plugins>
<groupId>org.sonarsource.scanner.maven</groupId> <plugin>
<artifactId>sonar-maven-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>3.3.0.603</version> <artifactId>maven-clean-plugin</artifactId>
<executions> <version>3.1.0</version>
<execution> </plugin>
<phase>verify</phase> <plugin>
<goals> <groupId>org.apache.maven.plugins</groupId>
<goal>sonar</goal> <artifactId>maven-resources-plugin</artifactId>
</goals> <version>3.1.0</version>
</execution> </plugin>
</executions> <plugin>
</plugin> <groupId>org.apache.maven.plugins</groupId>
<plugin> <artifactId>maven-compiler-plugin</artifactId>
<groupId>org.jacoco</groupId> <version>3.7.0</version>
<artifactId>jacoco-maven-plugin</artifactId> <configuration>
<version>0.8.1</version> <source>${java.version}</source>
<configuration> <target>${java.version}</target>
<append>true</append> </configuration>
</configuration> </plugin>
<executions> <plugin>
<execution> <groupId>org.apache.maven.plugins</groupId>
<id>prepare-agent</id> <artifactId>maven-surefire-plugin</artifactId>
<goals> <version>2.22.0</version>
<goal>prepare-agent</goal> </plugin>
</goals> <plugin>
</execution> <groupId>org.apache.maven.plugins</groupId>
<execution> <artifactId>maven-jar-plugin</artifactId>
<id>prepare-agent-integration</id> <version>3.1.0</version>
<goals> </plugin>
<goal>prepare-agent-integration</goal> <plugin>
</goals> <groupId>org.apache.maven.plugins</groupId>
</execution> <artifactId>maven-javadoc-plugin</artifactId>
<execution> <version>3.0.1</version>
<id>jacoco-site</id> <configuration>
<phase>verify</phase> <show>public</show>
<goals> <failOnError>false</failOnError>
<goal>report</goal> <additionalJOption>-Xdoclint:none</additionalJOption>
</goals> </configuration>
</execution> <executions>
</executions> <execution>
</plugin> <id>attach-javadocs</id>
</plugins> <goals>
</pluginManagement> <goal>jar</goal>
</build> </goals>
<profiles> </execution>
<profile> </executions>
<id>sonar</id> </plugin>
<properties> <plugin>
<sonar.host.url>https://sonarcloud.io</sonar.host.url> <groupId>org.apache.maven.plugins</groupId>
<sonar.organization>tastybento-github</sonar.organization> <artifactId>maven-source-plugin</artifactId>
</properties> <version>3.0.1</version>
<build> <executions>
<plugins> <execution>
<plugin> <id>attach-sources</id>
<groupId>org.jacoco</groupId> <goals>
<artifactId>jacoco-maven-plugin</artifactId> <goal>jar-no-fork</goal>
</plugin> </goals>
<plugin> </execution>
<groupId>org.sonarsource.scanner.maven</groupId> </executions>
<artifactId>sonar-maven-plugin</artifactId> </plugin>
</plugin> <plugin>
</plugins> <groupId>org.apache.maven.plugins</groupId>
</build> <artifactId>maven-shade-plugin</artifactId>
</profile> <version>3.1.1</version>
</profiles> <configuration>
<dependencies> <minimizeJar>false</minimizeJar>
<dependency> </configuration>
<groupId>org.spigotmc</groupId> </plugin>
<artifactId>spigot-api</artifactId> <plugin>
<version>1.13-R0.1-SNAPSHOT</version> <groupId>org.apache.maven.plugins</groupId>
<scope>provided</scope> <artifactId>maven-install-plugin</artifactId>
</dependency> <version>2.5.2</version>
<dependency> </plugin>
<groupId>org.mockito</groupId> <plugin>
<artifactId>mockito-all</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>1.10.19</version> <artifactId>maven-deploy-plugin</artifactId>
<scope>test</scope> <version>2.8.2</version>
</dependency> </plugin>
<dependency> <plugin>
<groupId>org.powermock</groupId> <groupId>org.jacoco</groupId>
<artifactId>powermock-module-junit4</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>${powermock.version}</version> <version>0.8.1</version>
<scope>test</scope> <configuration>
</dependency> <append>true</append>
<dependency> </configuration>
<groupId>org.powermock</groupId> <executions>
<artifactId>powermock-api-mockito</artifactId> <execution>
<version>${powermock.version}</version> <id>pre-unit-test</id>
<scope>test</scope> <goals>
</dependency> <goal>prepare-agent</goal>
<dependency> </goals>
<groupId>org.mongodb</groupId> </execution>
<artifactId>mongodb-driver</artifactId> <execution>
<version>3.6.3</version> <id>post-unit-test</id>
</dependency> <goals>
</dependencies> <goal>report</goal>
<repositories> </goals>
<repository> </execution>
<id>spigot-repo</id> </executions>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url> </plugin>
</repository> </plugins>
</repositories> </build>
<version>FC-0.9</version>
<profiles>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>tastybento-github</sonar.organization>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>5.1</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>

2
plugin.yml → src/main/resources/plugin.yml Executable file → Normal file
View File

@ -1,6 +1,6 @@
name: BentoBox name: BentoBox
main: world.bentobox.bentobox.BentoBox main: world.bentobox.bentobox.BentoBox
version: ${version} version: ${project.version}
api-version: 1.13 api-version: 1.13
authors: [tastybento, Poslovitch] authors: [tastybento, Poslovitch]

View File

@ -22,10 +22,11 @@ import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.junit.BeforeClass; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox; import org.powermock.reflect.Whitebox;
@ -36,7 +37,7 @@ import world.bentobox.bentobox.managers.IslandsManager;
import world.bentobox.bentobox.managers.PlayersManager; import world.bentobox.bentobox.managers.PlayersManager;
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest( { BentoBox.class }) @PrepareForTest( { BentoBox.class, Bukkit.class })
public class AddonTest { public class AddonTest {
@Mock @Mock
@ -44,8 +45,8 @@ public class AddonTest {
static JavaPlugin javaPlugin; static JavaPlugin javaPlugin;
@BeforeClass @Before
public static void setUpBeforeClass() throws Exception { public void setUp() throws Exception {
Server server = mock(Server.class); Server server = mock(Server.class);
World world = mock(World.class); World world = mock(World.class);
when(server.getLogger()).thenReturn(Logger.getAnonymousLogger()); when(server.getLogger()).thenReturn(Logger.getAnonymousLogger());
@ -55,8 +56,10 @@ public class AddonTest {
PluginManager pluginManager = mock(PluginManager.class); PluginManager pluginManager = mock(PluginManager.class);
when(server.getPluginManager()).thenReturn(pluginManager); when(server.getPluginManager()).thenReturn(pluginManager);
Bukkit.setServer(server); //Bukkit.setServer(server);
PowerMockito.mockStatic(Bukkit.class);
when(Bukkit.getServer()).thenReturn(server);
when(Bukkit.getPluginManager()).thenReturn(pluginManager);
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger()); when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
plugin = mock(BentoBox.class); plugin = mock(BentoBox.class);
@ -100,7 +103,8 @@ public class AddonTest {
@Test @Test
public void testGetConfig() { public void testGetConfig() {
TestClass test = new TestClass(); TestClass test = new TestClass();
assertNotNull(test.getConfig()); // No config file
assertNull(test.getConfig());
} }
@Test @Test