英文:
Maven-compiler-plugin throws wanted compile errors but deny the compile progress
问题
几天前我开始使用Maven。我只需要将我生成的jar文件中的一些依赖项放入其中。这是必要的,因为我的代码只是一个插件(Minecraft插件),由API(Minecraft服务器软件Spigot)执行。现在的问题是,我的插件依赖于另一个API(json-simple-1.1)。
过去几天里,我尝试编辑Maven Shade插件以获得所需的结果。我失败了,现在我是这样做的:
- Maven包含我插件所需的json-simple-1.1 API
- Eclipse包含Spigot API(Minecraft服务器软件),将执行我的插件
pom.xml:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<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>de.falco.essentialsXXX</groupId>
<artifactId>EssentialsXXX-bungeecord</artifactId>
<version>0.0.1-SNAPSHOT</version>
<description>Basic class for every Plugin</description>
<build>
<sourceDirectory>src</sourceDirectory>
<!-- COMPILE -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- BUILD -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-json</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
<!-- end snippet -->
当我现在在正确的目录中执行'mvn clean install'时,会出现许多错误。这完全合理。Maven找不到来自Spigot API的类型或类以及其他一切。
我的问题是,这不是真正的错误,因为当Spigot API执行我的插件时,我会获得所需的类和类型。Maven不知道这一点,不会编译我的程序:(
在这一点上,我不知道该怎么办。我阅读了很多文章,但找不到解决方案。每篇文章都说,哦,这里有一个错误,尝试使用
我需要像编译器的“bypass”属性一样的东西,这样编译器就知道,“是的,这是一个错误,但编码人员知道自己在做什么”。
英文:
A few days ago i started with Maven. I have to put only a few of my dependencies in my generated jar file. This is needed because my code is only a plugin (Minecraft Plugin) executed by an api (Minecraft Server Software Spigot). Now the Problem is, that my Plugin depends on an other api (json-simple-1.1).
The last days i tried to edit the maven shade plugin to get the wished result. I failed, and now i did it in this way:
- maven include the json-simple-1.1 api, i needing for my plugin
- eclipse include the spigot api (Minecraft server software), which will executing my plugin
pom.xml:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<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>de.falco.essentialsXXX</groupId>
<artifactId>EssentialsXXX-bungeecord</artifactId>
<version>0.0.1-SNAPSHOT</version>
<description>Basic class for every Plugin
</description>
<build>
<sourceDirectory>src</sourceDirectory>
<!-- COMPILE -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- BUILD -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-json</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
<!-- end snippet -->
When i now execute 'mvn clean install' (in the right directory) i get many many errors. That make completely sense. Maven can not find types or classes and everything else comeing from the spigot-api.
My Problem is, that this isnt a real error because when the spigot-api execute my plugin i have the classes and types i need. Maven dont know that and dont compile my Programm
At this point a have no idea what to do. I read so many articles but i couldnt find a solution. Every article say ohhh an error here try to use <depdency> tags and the right api values. That isnt what i need.
I need something like a "bypass" attribute for the compiler so the compiler know "yes this is an error but the coder knows what he does"
答案1
得分: 0
如果您需要用于编译的内容,它需要是一个Maven依赖项。
因此,获取该构件,将其安装到您的本地仓库,并将其添加为依赖。
然后您的编译过程可能会正常工作。
请注意,使用依赖项并不意味着您必须将该依赖项包含在生成的jar包中。
英文:
If you need something for compilation, it needs to be a Maven dependency.
So take that artifact, install it in your local repository and add it as dependency.
Then your compilation process will probably work.
Note that using a dependency does not mean that you have to include the dependency into the resulting jar.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论