Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3984728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:48:18+00:00 2026-05-20T05:48:18+00:00

I am using mvn eclipse:eclipse command to generate my .project and .classpath . However,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:48:18+00:00Added an answer on May 20, 2026 at 5:48 am

    It depends on what that line is.

    1. If it’s a source folder, use the
      buildhelper-maven-plugin to
      add a source folder in a
      lifecycle phase before
      generate-sources, this will
      automatically be picked up by the
      eclipse plugin.
    2. If it’s a classpath container, you
      can use the classpathContainers
      parameter
    3. If you want to change the output folders (from target/classes and target/test-classes to something else), change them in the maven build configuration:

      <build>
          <!-- replace "target" -->
          <directory>somedir</directory>
          <!-- replace "target/classes" -->
          <outputDirectory>anotherdir</outputDirectory>
          <!-- replace "target/test-classes" -->
          <testOutputDirectory>yetanotherdir</testOutputDirectory>
      </build>
      

      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 and testOutputDirectory inside directory (usually by referencing ${project.build.directory}), otherwise you break standard functionality like mvn clean (it cleans ${project.build.directory}):

      <build>
          <directory>bin</directory>
          <outputDirectory>${project.build.directory}/main-classes
          </outputDirectory>
          <!-- this config will replace "target" with "bin",
               compile src/main/java to "bin/main-classes"
               and compile src/test/java to "bin/test-classes"
               (because the default config for <testOutputDirectory> is
               ${project.build.directory}/test-classes )
          -->
      </build>
      

    Reference:

    • POM Reference > Build > The BaseBuild Element Set
    • POM Reference > Build > Directories
    • Introduction to the POM > Available Variables

    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:

    1. Define a <profile> named eclipse (or whatever)
    2. Define an execution of the gmaven plugin (use this version)
    3. Write a short groovy script (inline in the pom or external) that checks the .classpath file for your classpath container and adds it if missing (bind execution to a lifecycle phase, e.g. generate-resources)
    4. set the profile activation to <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:

    mvn eclipse:eclipse    # two separate executions
    mvn generate-resources # here, profile will be active
    

    or perhaps this will also work:

    mvn -Peclipse eclipse:eclipse generate-resources
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My (simple) war project builds fine using mvn:package at the command line, but fails
COMMAND: mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate -DarchetypeGroupId=org.beardedgeeks -DarchetypeArtifactId =gae-eclipse-maven-archetype -DarchetypeVersion=1.1.2 -DarchetypeRepository=http://beardedgeeks.googlecode.com/svn/repository/release s OUTPUT: [INFO] Scanning for projects...
I'm having maven project on Eclipse with m2eclipse plugin. This project has some dependencies.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using JDeveloper , I started developing a set of web pages for a project
I don't use the Eclipse maven plugin while developing in Eclipse. I generate my
We recently started using maven for dependency management. Our team uses eclipse as it's
I am trying to create a Eclipse project from Hibernate tutorials under path \hibernate-distribution-3.5.3-Final\project\tutorials\eg
I have a maven project where I am using the assembly plugin. I typically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.