나는 현재 Minecraft Plugin을 테스트 하기 위해 MockBukkit 을 사용하려고 시도 하고 있으며 테스트 범위와 함께 내 pom에 포함 시켰습니다. 그러나 문제는 테스트 범위를 사용할 때 종속성이 내 로컬 저장소에 나타나지만 eclipse 또는 Maven으로 해결할 수 없다는 것입니다.
문제는 컴파일러 플러그인 의 기본 컴파일 목표가 테스트 단계에서만 사용할 수 있으므로 종속성을 사용할 수 없더라도 테스트 클래스를 컴파일하려고한다는 것입니다. (그러나 그것은 내 추측 일뿐입니다).
Maven 출력 :
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ CityCraft ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 32 source files to C:\Users\lptoa\Desktop\MC Plugins\CityCraft\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[3,32] package be.seeseemelk.mockbukkit does not exist
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[4,32] package be.seeseemelk.mockbukkit does not exist
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[9,17] cannot find symbol
symbol: class ServerMock
location: class test.java.skyvide.de.city.CityTests
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[12,10] cannot find symbol
symbol: class Before
location: class test.java.skyvide.de.city.CityTests
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[19,10] cannot find symbol
symbol: class After
location: class test.java.skyvide.de.city.CityTests
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[15,22] cannot find symbol
symbol: variable MockBukkit
location: class test.java.skyvide.de.city.CityTests
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[16,34] cannot find symbol
symbol: variable MockBukkit
location: class test.java.skyvide.de.city.CityTests
[ERROR] /C:/Users/lptoa/Desktop/MC Plugins/CityCraft/src/test/java/skyvide/de/city/CityTests.java:[22,13] cannot find symbol
symbol: variable MockBukkit
location: class test.java.skyvide.de.city.CityTests
위치:
->src
--->test
--->java
--->example
--->ExampleTest.java
암호:
package test.java.example;
import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import main.plugin;
public class ExampleTest {
private ServerMock server;
private Plugin plugin;
@Before
public void setUp()
{
server = MockBukkit.mock();
plugin = (Plugin) MockBukkit.load(Plugin.class);
}
@After
public void tearDown()
{
MockBukkit.unmock();
}
}
POM :
<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>sv-plugins</groupId>
<artifactId>CityCraft</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>testing</id>
<activation>
<property>
<name>test.output.dir</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>${test.output.dir}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>everything</id>
<url>https://repo.citizensnpcs.co/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.github.WesJD.AnvilGUI:anvilgui</include>
<include>co.aikar:acf-paper</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens</artifactId>
<version>2.0.27-SNAPSHOT</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>sv-plugins</groupId>
<artifactId>MySQL</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>sv-plugins</groupId>
<artifactId>Clouds</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.WesJD.AnvilGUI</groupId>
<artifactId>anvilgui</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.16</artifactId>
<version>0.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
좋아요, 오류는 방금 기본 이클립스 프로젝트를 Maven 프로젝트로 변환했기 때문에 .classpath를 변경해야했기 때문에 빌드 경로에서 기본 src 폴더를 제거하고 다른 Maven 폴더를 추가해야했습니다. 그것 없이는 Maven은 모든 클래스를 실패하게 만든 테스트가 아닌 일반 클래스로 컴파일하려고했습니다.
누군가가 관심이있는 경우 두 .classpath 파일 간의 비교는 다음과 같습니다.
낡은:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
새로운:
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다