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

  • Home
  • SEARCH
  • 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 8792161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:56:29+00:00 2026-06-13T22:56:29+00:00

Within a custom gradle plugin the project.version seems to always be unspecified . Why

  • 0

Within a custom gradle plugin the project.version seems to always be unspecified. Why and how to retrieve the project.version within a custom plugin (class)?

For Example:

apply plugin: 'java'
apply plugin: MyPlugin

version = "1.0.0"

println "In build file: $project.version" 

class MyPlugin implements Plugin<Project> {
  public void apply(Project project) {
    project.task('myTask') {
      println "In plugin: $project.version"
    }
  }
}

Prints out:

%> gradle -q myTask
  In plugin: unspecified
  In build file: 1.0.0

Besides the how I really would like to know the why?

  • 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-06-13T22:56:30+00:00Added an answer on June 13, 2026 at 10:56 pm

    You set the property after you call apply

    If you move

    version = "1.0.0"
    

    To before the line

    apply plugin: MyPlugin
    

    It should work

    Edit

    Following Peter’s answer, you can see that this works also:

    apply plugin: 'java'
    apply plugin: MyPlugin
    
    version = "1.0.0"
    
    println "In build file: $project.version" 
    
    class MyPlugin implements Plugin<Project> {
      public void apply(Project project) {
        project.task('myTask') {
          project.gradle.projectsEvaluated { 
            println "In plugin: $project.version"
          }
        }
      }
    }
    

    To delay the evaluation of $project.version until evaluation of the build is complete

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In javascript I need to get the text within the custom tag. For example
Is it possible to execute a script within a custom Xcode 4 project file
Within my custom cell there are 2 span-elements. <span class=FormElement> <span class=customelement id=code name=code>BER01_CN_045_002</span>
Hey, I am having problems accessing a variable within a custom annotation class I
Can I update only selected variables within a custom EventArgs class or do I
I need to retrieve the text from a textbox within a custom control. The
Working on figuring out my NullPointerException within my custom simplecursoradapter when trying to refresh
Is it possible to call another JSF component from within a custom component (as
I have implemented a custom view within another activity into a XML layout. The
I'm trying to style a custom menu within drupal. I've sucessfully styled to display

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.