By maxi175


2019-07-11 15:52:53 8 Comments

as it was mentioned in the title I have Gradle Multi-Project contains java-library. I cannot find way to add clean and javadoc task before jar task execution.

This is my current build.gradle file

apply plugin:'java'

task printRootProjectInfo{
    println '----- Project info -----'
    println 'Project name: ' + rootProject.name
    println 'Subprojects: '
    subprojects.findAll { subproject -> println "    $subproject.name" }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}

subprojects{
    jar {
        dependsOn clean
    }
}

//todo: add `clean` task before each `jar` task for subprojects
//def printProjectInfo  = {
//    println '====== Start processing subproject ======'
//    println "______ $rootProject.name ==>  $project.name"
//}

I found code on StackOverFlow where someone manage to invoke simple print command for each project but cannot find example with dependOn syntax.

I try to use syntax:

subprojects{
    jar {
        dependsOn clean
    }
}

but it seems to have no effect.

Could you provide an example?

I use Gradle 5.5.1

1 comments

@maxi175 2019-07-16 15:55:24

If anyone needs answer for this, here is syntax which works for me:

subprojects {
    apply plugin: 'java-library'
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'

    tasks.jar.dependsOn("clean")
}

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] Can't define task dependencies between multiple projects using gradle

  • 2018-10-17 01:59:25
  • Gloria Santin
  • 148 View
  • 0 Score
  • 2 Answer
  • Tags:   gradle

0 Answered Questions

Get variable from child project in subproject configuration in multi module gradle project

  • 2018-03-05 13:10:37
  • Syngularity
  • 276 View
  • 3 Score
  • 0 Answer
  • Tags:   java gradle

2 Answered Questions

[SOLVED] Why some Gradle subproject tasks are accessible from root project?

  • 2017-09-20 06:30:10
  • Karolis
  • 500 View
  • 0 Score
  • 2 Answer
  • Tags:   java gradle

1 Answered Questions

[SOLVED] Gradle multi-project build with liquibase

1 Answered Questions

[SOLVED] Gradle dependson vs. defaultTasks in multi-project

  • 2017-01-20 17:17:42
  • Axel
  • 476 View
  • 2 Score
  • 1 Answer
  • Tags:   gradle

1 Answered Questions

[SOLVED] Gradle Multi-Project Task Execution Behaviour

2 Answered Questions

1 Answered Questions

[SOLVED] Get project name of task in gradle

  • 2015-03-31 12:02:34
  • mrzodiak
  • 13300 View
  • 7 Score
  • 1 Answer
  • Tags:   groovy gradle

1 Answered Questions

0 Answered Questions

defining clean task on rootProject overrides default clean task in java subprojects

  • 2014-05-08 08:52:57
  • coderatchet
  • 350 View
  • 0 Score
  • 0 Answer
  • Tags:   java groovy gradle

Sponsored Content