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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:27:02+00:00 2026-06-18T14:27:02+00:00

I have a multi-project (multiple java subprojects) in Grade and I plan to upload

  • 0

I have a multi-project (multiple java subprojects) in Grade and I plan to upload it to a maven repository (currently a local one) including the sources and javadoc artifacts. I simply add the following code to each subproject and then maven install does the job:

apply plugin: 'maven'

task sourcesJar(type: Jar, dependsOn:classes) {
        from sourceSets.main.allSource 
        classifier = 'sources' 
} 
task javadocJar(type: Jar, dependsOn:javadoc) {
        from javadoc.destinationDir 
        classifier = 'javadoc' 
}
artifacts { 
        archives jar
        archives sourcesJar 
        archives javadocJar 
}

Now its not that nice to have the same code in 10 subprojects, so I decided I will move this code into the subprojects { ... } configuration of the parent project. However, now it does not work anymore: Only empty sources and javadoc jars are built, the normal jar is ignored, and maven install does not copy the files anymore to the local maven repository. How to do this right?

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-06-18T14:27:03+00:00Added an answer on June 18, 2026 at 2:27 pm

    A parent project’s build script gets evaluated before its subprojects’ build scripts. When you lift some code to a parent project’s build script, you’ll have to make sure that the evaluation order stays intact, i.e. that the lifted code doesn’t eagerly read properties that are only set by a subproject’s build script. For example, if javadoc.destinationDir is set by a subproject’s build script, you’ll either have to lift that code too, or defer evaluation of the from javadoc.destinationDir expression in the parent build script.

    There are several techniques for deferring evaluation. Some properties (like an archive task’s from and into) accept a closure; hence you can simply do from { javadoc.destinationDir }. Another option is to use hooks like gradle.projectsEvaluated {}, project.afterEvaluate {}, or task.doFirst {}. The first step in deciding which technique to use is to look up the property in question in the Gradle Build Language Reference.

    Without seeing more of your build scripts, my best guess is that your particular problems are related to not lifting apply plugin: "java" into the parent build script’s subprojects {} block.

    An alternative to configuration injection (e.g. via subprojects {}) is to put common code into a separate build script, and have project build scripts include that code with apply from:. In some cases, this is an easier way to (selectively) share code than configuration injection. Often, the two approaches are used together.

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

Sidebar

Related Questions

I have a multi-module Maven setup with Java code. My unit tests, in one
We have a multi-module maven project that uses a profile that defines a buildnumber-maven-plugin
I have a Maven multi-module project and I need two different parent POMs in
I have created a multi module maven project. Now I have shared the project
I have a multi-module Maven project, and I would like to assemble together artifacts
I’m starting a multi project solution that will have more than one entry point,
I have this maven multi-project configuration with a parent project and three child projects:
I have been working on this project on Java with multiple modules. Since quite
I have checked in a maven multi module project.If I check in in normal
I have a multi module maven project containing a common model project and two

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.