Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Incorporate Magritte approach that avoids having to copy write-version.gradle #12

Open
eshlin opened this issue May 25, 2016 · 1 comment

Comments

@eshlin
Copy link

eshlin commented May 25, 2016

@iamdanfox mentioned that Magritte has an approach that avoids the need to copy over write-version.gradle. It would be great to incorporate this into the plugin so users of dropwizard-version-info don't have to copy over the the write-version.gradle file.

"We’ve actually ended up with a way nicer way of doing version stuff in Magritte
we add a sourceSet called generated_resources, which gradle puts the version file in
It’s might be quite easy to pluginize and should eliminate the need to copy the write-version.gradle file"

@iamdanfox
Copy link
Contributor

This approach involves adding a source set to main:

sourceSets {
  main {
    output.dir("$buildDir/generated_resources/main", builtBy: 'generateVersionFile')
  }
}

This task then just needs to write the file somehow...

task generateVersionFile {
  def versionFile = file("$buildDir/generated_resources/main/version.properties")
  outputs.file versionFile
  inputs.properties version: version // necessary to make task refresh properly

  doLast {
    versionFile.text = "version: ${version}"
  }
}

I think it might be neater to express this a Copy task... as usual, there are a million ways to do everything.

Upsides of this approach: it will work if you run ./gradlew eclipse or ./gradlew idea, as well as ./gradlew compileJava.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants