Eclipse settings affect Maven command line build?

Most of our projects are built with Maven, and some of them use classes in the com.sun package. This is bad practice, but I can't help it.

For a while, this was not a big problem. Then, at some point, the builds started crashing for me with errors like:

java.lang.Error: Unresolved compilation problems:
        Access restriction: The type TextSerializer is not accessible due to res
triction on required library C:\Program Files\Java\jre1.5.0_15\lib\rt.jar

This is true, but I could not understand for life how to disable this check. Lines were not executed either from the command line or from Eclipse, so I assumed that this should be a Maven setting.

In the end, I realized that the problem was somehow with Eclipse . I went to Preferences> Java> Compiler> Errors / Warnings> Deprecated and restricted API and changed the "Forbidden Directory" to "Warning". After that, my builds began to work. This is completely incomprehensible to me, because I got errors when building from the command line .

Can someone explain to me how the Eclipse parameter can somehow influence the behavior of the assembly from the command line ?!

+3
source share
5 answers

, FAQ m2eclipse, , FAQ:

, rt.jar, com.sun.* ( ) : " : RE - /lib/rt.jar". , API, Eclipse JDT.

/ /Java// // API/ ( )/; / /// Java / API/ ( )/

, , JDK Eclipse. , , Eclipse JRE, Maven, ... Maven JDK ( javac). , , javac, compilerId, -. - :

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <compilerId>eclipse</compilerId>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-compiler-eclipse</artifactId>
      <version>xxxx</version>
    </dependency>
  </dependencies>
</plugin>

- eclipse , -, .

:. , OP.

, mvn clean compile :

mvn clean install

, , ( ). : Eclipse .class . , ( ) maven, clean.

, , Maven Eclipse, . m2eclipse 0.9.4. dev-list.

+4

Eclipse Maven CLI:

pom.xml. m2e.version , Eclipse

<profiles>
  <profile>
    <id>IDE</id>
    <activation>
      <property>
        <name>m2e.version</name>
      </property>
    </activation>
    <build>
      <!-- Put the IDE build output in a folder other than target, so that IDE builds don't interact with Maven builds -->
      <directory>target-ide</directory>
    </build>
</profile>
+1

, mvn clean install . , (M2) Eclipse , , , Maven , . . , , .

0

, "" - , , , - , .. , .

,

java.lang.Error: :

0

I see similar problems using Netbeans (6.9.1) with the Maven project. mvn cleanfixes the problem.

0
source

Source: https://habr.com/ru/post/1719746/


All Articles