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 7684779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:06:22+00:00 2026-05-31T19:06:22+00:00

I have the same question for Maven that someone had about Ant ( How

  • 0

I have the same question for Maven that someone had about Ant (How can I get the name of the last folder in my basedir path in Ant?).

How do you get just the last directory name from the variable ${project.basedir}?

For example, if my pom.xml is in:

/home/me/project/pom.xml

Then ${project.basedir} = /home/me/project/

I want just the directory name ‘project’.

Thanks!

  • 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-31T19:06:23+00:00Added an answer on May 31, 2026 at 7:06 pm

    Use: ${project.file.parentFile.name}

    How to work it out:

    The ${project} actually resolved to a MavenProject object. From there, you can just use bean properties to get the value you need. In this case:

    • use the file property (through getFile())
    • use the parentFile property on java.io.File (through getParentFile())
    • use the name property of the File to get just the name without path information (through getName())

    (edit: after comment)

    It’s not a good idea to use properties for artifact IDs. The ${project.file.parentFile.name} property cannot be resolved when using it as part of artifactId, however some properties do work (project.groupId for the artifactId seems to work).

    However, this is not recommended. In fact, if you use any property for the artifact ID instead of a constant, you’ll get a warning when you build your project:

    [WARNING] Some problems were encountered while building the effective model for <your groupID>:<your artifactID>:jar:1.0-SNAPSHOT
    [WARNING] 'artifactId' contains an expression but should be a constant. @ <your groupID>:<your artifact ID>:1.0-SNAPSHOT, <basedir>/pom.xml, line 5, column 14
    [WARNING] 
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING] 
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about how to access the member with the same name
vb.net windows forms question. I've got 3 forms that have exactly the same functions,
I have the same question that was asked in another post except I'm having
i have some questions about Maven 2 and i hope somebody can clear things
I have the same question problem as described here How to purge a cached
I have the same question as #1895500 , but with PostgreSQL not MySQL. How
The question I have is exactly same in requirement as How to pass mouse
I have basically the same problem outlined in this question, however I am using
I have an ObjectDataSource (but perhaps this question is the same for all kinds
This is probably an easy question... I have 4 source versions of the same

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.