I am using mvn eclipse:eclipse
command to generate my .project
and .classpath
.
However, for some reasons, I want to add one line in the .classpath
file. Is there a configuration in my pom.xml
that I can use to achieve that?
Note that <additionalConfig>
cannot be used, as this will erase the content of the .classpath
.
I am using maven 3.0.2 and maven-eclipse-plugin 2.8.
It depends on what that line is.
generate-sources
, this will automatically be picked up by the eclipse plugin.If you want to change the output folders (from
target/classes
andtarget/test-classes
to something else), change them in the maven build configuration:You can configure each of those three independently, and the changes will be picked up by the eclipse plugin, but it's considered good practice to put
outputDirectory
andtestOutputDirectory
insidedirectory
(usually by referencing${project.build.directory}
), otherwise you break standard functionality likemvn clean
(it cleans${project.build.directory}
):Reference:
Update: in your case I guess the only possible solution is to programmatically edit the
.classpath
file. What I would probably do is something like this:<profile>
named eclipse (or whatever)generate-resources
)<file><exists>${project.basedir}/.classpath</exists></file>
(because you only want it to be active in an eclipse project)The problem with this solution:
eclipse:eclipse
is a goal, not a phase, so it's not possible to execute this automatically, so you'll have to do something like this:or perhaps this will also work: