How to set eclipse project specific validation preferences with m2e

我只是一个虾纸丫 提交于 2020-01-06 19:43:51

问题


When invoking importing maven projects into eclipse from git using "Import Maven Projects" the m2e plugins to seems to generate a new .project and .classpath and some other files even though those files are checked in.

To get around this problem I would like to not check in any eclipse specific files, but there are customizations made to each project file such as custom save actions, or changes to the validation to ignore specific things, or changes to the javascript configuration for a dynamic web project that need to be preserved, so either those files need to checked or those settings need to be generated by m2e.

Any way to use m2e to configure the eclipse project validators?


回答1:


We had a similar problem in the past. We solved it by

  • don't checkin eclipse specific files (svn ignore, git ignore, ...)
  • Use Workspace Mechanic plugin to keep eclipse settings the same accross development machines / developers.



回答2:


The other answer has suggested the solution with eclipse. But if you are flexible with using a different IDE, I suggest using Netbeans with git. I tested both IDEs and finally found out I could save time in different cases using Netbeans! No such problems as mentioned above.




回答3:


I made m2e-codestyle-maven-plugin for another purpose but it should serve what you need as well (in my case I wanted to set the default settings to have all validations turned on from my coding-standards project.

The key thing you have to do is fork a copy of my coding-standards project and add/change the appropriate setting in org.eclipse.wst.validation.prefs namely

vals/org.eclipse.wst.xml.core.xml/global=FF03

To disable the validations for XML for example. You can have it activated only on m2e by using profiles as shown here

https://github.com/trajano/jee/blob/master/jee-domain-api/pom.xml#L24

<profile>
  <id>m2e</id>
  <activation>
    <property>
      <name>m2e.version</name>
    </property>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>net.trajano.mojo</groupId>
        <artifactId>m2e-codestyle-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>configure</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>net.trajano</groupId>
            <artifactId>coding-standards</artifactId>
            <version>${coding-standards.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</profile>


来源:https://stackoverflow.com/questions/14006325/how-to-set-eclipse-project-specific-validation-preferences-with-m2e

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!