区分大小写的软件包上的Maven + plexus + eclipse编译器中可能存在错误? [英] possible bug in Maven + plexus + eclipse compiler on case sensitive packages?

查看:150
本文介绍了区分大小写的软件包上的Maven + plexus + eclipse编译器中可能存在错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Maven和Eclipse编译器时遇到一个非常奇怪的问题.

I encounter a very strange problem with Maven and Eclipse compiler.

在Eclipse + m2eclipse中,使用以下单个类编译小型项目(原型快速入门)没有问题.

While in Eclipse+m2eclipse, I have no problem compiling a small project (archetype quick start) with the following single class.

package test.test;
import com.Ostermiller.util.CSVParser;
public class TestCaseSensitive {
    CSVParser csvParser;
}

Ostermiller utils已添加到pom.xml. Eclipse Kepler编译该项目. 接下来,mvn compile即开即用.

Ostermiller utils is added to pom.xml. Eclipse Kepler compiles the project. Next, mvn compile works out-of-the-box.

现在是问题,我切换到编译器3.1,并要求使用Eclipse编译器(以便能够在控制台模式和IDE模式下处理相同的编译问题).这是POM:

Now the issue, I switch to compiler 3.1 and asks for Eclipse compiler (to be able to handle same compilation issues in console mode as well as IDE mode). This is the 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>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

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

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.ostermiller</groupId>
        <artifactId>utils</artifactId>
        <version>1.07.00</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <compilerId>eclipse</compilerId>
                <source>1.7</source>
                <target>1.7</target>
                <optimize>true</optimize>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
                <fork>false</fork>
                <compilerArgument>-err:nullAnnot,null</compilerArgument>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-compiler-eclipse</artifactId>
                    <version>2.2</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

现在是结果:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure: Compilation failure:
[ERROR] /home/me/workspaces/4/3/ws/test/src/main/java/test/test/TestCaseSensitive.java:[3] The import com.Ostermiller cannot be resolved
[ERROR] /home/me/workspaces/4/3/ws/test/src/main/java/test/test/TestCaseSensitive.java:[7] CSVParser cannot be resolved to a type

com.Ostermiller软件包存在(它在maven默认编译器中也可以在Eclipse IDE中进行编译),但是在切换到eclipse编译器之后不存在.

The package com.Ostermiller exists (it compiles in maven default compiler as well in Eclipse IDE), but not after switching to eclipse compiler.

请注意,报告的错误路径也是错误的:

Please note that the reported error path is also wrong :

[ERROR] /home/me/workspaces/4/3/ws/test/src/main/java/...

应该是

[ERROR] /home/me/workspaces/4.3/ws/test/src/main/java/...

有人有想法吗?应该在哪里报告潜在的错误?

Has someone an idea? Where shall the potential bug be reported?

推荐答案

您是否尝试过使用tycho提供的jdt编译器?

Have you tried using the jdt compiler provided by tycho?

请参见 http://wiki.eclipse.org/Tycho/FAQ #Can_I_use_the_Tycho_compiler_support_in_non-OSGi_projects.2C_too.3F

那会给你:

<plugin>
  <!-- Use compiler plugin with tycho as the adapter to the JDT compiler. -->
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
     <compilerId>jdt</compilerId>
     <source>1.7</source>
     <target>1.7</target>
     <optimize>true</optimize>
     <showWarnings>true</showWarnings>
     <showDeprecation>true</showDeprecation>
     <fork>false</fork>
     <compilerArgument>-err:nullAnnot,null</compilerArgument>
  </configuration>
  <dependencies>
     <!-- This dependency provides the implementation of compiler "jdt": -->
     <dependency>
       <groupId>org.eclipse.tycho</groupId>
       <artifactId>tycho-compiler-jdt</artifactId>
       <version>${tycho-version}</version>
     </dependency>
   </dependencies>
</plugin>

当前tycho-version = 0.18.0

Currently tycho-version=0.18.0

这篇关于区分大小写的软件包上的Maven + plexus + eclipse编译器中可能存在错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆