Distribution plugin cannot create distribution without source code


(Frank) #1

.Distribution and application plugins cannot create distribution without source files. It assumes that the source for the distribution is one almighty monolith project (and/or subprojects) that all have source files locally.
A distribution should be able to be created from existing wars, jars, dependencies of those wars and jars, zip files, etc. that are already built and published to maven/artifactory. The distribution project itself should not need to have source files or to have to compile source at all. And since those artifacts need not be java the “java” plugin should not be required to create a distribution.
In the current implementation of those plugins looks like it always wants the “from” to be something from the local file system whether it be source files or compiled targets.
I’d like to be able to create a distribution from artifacts.
This war from this artifact into this directory.
This application zip created from the application plugin from this zip artifact into this other directory,
These text files from this other artifact zip unzipped into another directory.
I think the functionality is loosely defined in the “future” of the design spec. Wondering if the spec is up to date? (perhaps maybe there are undocumented updates and this functionality already exists?). If not, how can I accomplish this goal?

https://github.com/gradle/gradle/blob/master/design-docs/building-and-packaging-applications-and-libraries.md


(Stefan Oehme) #2

Everything needs to be on the local filesystem before packaging, but that doesn’t mean that it has to be local source code. You could just as well package a bunch of jars from a configuration.

apply plugin: 'distribution'

repositories {
  jcenter()
}

configurations {
  libs
}

dependencies {
  libs "junit:junit:4.12"
}

distributions {
  main {
    contents {
      into('libs') {
        from configurations.libs
      }
    }
  }
}