Check if Java code works in Maven plugin

I am writing an Xtext-based code generator that can be called:

  • directly (using the method main(String[]))
  • inside Eclipse (as an Eclipse code generator plugin)
  • via 'xtext-maven-plugin'

Now I need to solve some problems related to Maven. To do this, I need to know if my code works in Maven or not.

My first idea was to check the system property maven.homeas follows:

if (System.getProperty("maven.home") != null) {
    // In Maven
}

Is there a better way to do this?

+4
source share
1 answer

Maven Maven, , pom.xml build/plugins/plugin, , Maven .

, " maven", , maven . , " maven", maven , ( , , , maven).

99% , , maven . , - , IDE. , - , Maven; , , .

maven (pom.xml), , java, IDE. , IDE, (, java 1.8), maven pom.xml (, Java 1.7).

+1

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


All Articles