Gradle build - Resolve dependencies from downloaded archive
up vote
0
down vote
favorite
I'm fairly new to Gradle. I have a multi-project build that uses some dependencies currently packaged within the project (using repositories and flatDir), as they're not available in an artifactory.
I want to remove this local folder and download a couple of archives holding these dependencies, unpack them and proceed with the build as regular. I will use https://plugins.gradle.org/plugin/de.undercouch.download for downloading, but I don't know how to this before any dependency resolution (and ideally, download if not already done). Currently, the build fails in the configuration phase as far as I can tell:
`A problem occurred configuring project ':sub-project-A'.
> Could not resolve all files for configuration ':sub-project-A:compileCopy'.
Could not find :<some-dependency>:.
EDIT: Downloading the files works. Still struggling with unzipping the archives:
task unzipBirt(dependsOn: downloadPackages, type: Copy) {
println 'Unpacking archiveA.zip'
from zipTree("${projectDir}/lib/archiveA.zip")
include "ReportEngine/lib"
into "${projectDir}/new_libs"
}
How do I make this run in the configuration phase ?
gradle download task multi-project external-dependencies
add a comment |
up vote
0
down vote
favorite
I'm fairly new to Gradle. I have a multi-project build that uses some dependencies currently packaged within the project (using repositories and flatDir), as they're not available in an artifactory.
I want to remove this local folder and download a couple of archives holding these dependencies, unpack them and proceed with the build as regular. I will use https://plugins.gradle.org/plugin/de.undercouch.download for downloading, but I don't know how to this before any dependency resolution (and ideally, download if not already done). Currently, the build fails in the configuration phase as far as I can tell:
`A problem occurred configuring project ':sub-project-A'.
> Could not resolve all files for configuration ':sub-project-A:compileCopy'.
Could not find :<some-dependency>:.
EDIT: Downloading the files works. Still struggling with unzipping the archives:
task unzipBirt(dependsOn: downloadPackages, type: Copy) {
println 'Unpacking archiveA.zip'
from zipTree("${projectDir}/lib/archiveA.zip")
include "ReportEngine/lib"
into "${projectDir}/new_libs"
}
How do I make this run in the configuration phase ?
gradle download task multi-project external-dependencies
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm fairly new to Gradle. I have a multi-project build that uses some dependencies currently packaged within the project (using repositories and flatDir), as they're not available in an artifactory.
I want to remove this local folder and download a couple of archives holding these dependencies, unpack them and proceed with the build as regular. I will use https://plugins.gradle.org/plugin/de.undercouch.download for downloading, but I don't know how to this before any dependency resolution (and ideally, download if not already done). Currently, the build fails in the configuration phase as far as I can tell:
`A problem occurred configuring project ':sub-project-A'.
> Could not resolve all files for configuration ':sub-project-A:compileCopy'.
Could not find :<some-dependency>:.
EDIT: Downloading the files works. Still struggling with unzipping the archives:
task unzipBirt(dependsOn: downloadPackages, type: Copy) {
println 'Unpacking archiveA.zip'
from zipTree("${projectDir}/lib/archiveA.zip")
include "ReportEngine/lib"
into "${projectDir}/new_libs"
}
How do I make this run in the configuration phase ?
gradle download task multi-project external-dependencies
I'm fairly new to Gradle. I have a multi-project build that uses some dependencies currently packaged within the project (using repositories and flatDir), as they're not available in an artifactory.
I want to remove this local folder and download a couple of archives holding these dependencies, unpack them and proceed with the build as regular. I will use https://plugins.gradle.org/plugin/de.undercouch.download for downloading, but I don't know how to this before any dependency resolution (and ideally, download if not already done). Currently, the build fails in the configuration phase as far as I can tell:
`A problem occurred configuring project ':sub-project-A'.
> Could not resolve all files for configuration ':sub-project-A:compileCopy'.
Could not find :<some-dependency>:.
EDIT: Downloading the files works. Still struggling with unzipping the archives:
task unzipBirt(dependsOn: downloadPackages, type: Copy) {
println 'Unpacking archiveA.zip'
from zipTree("${projectDir}/lib/archiveA.zip")
include "ReportEngine/lib"
into "${projectDir}/new_libs"
}
How do I make this run in the configuration phase ?
gradle download task multi-project external-dependencies
gradle download task multi-project external-dependencies
edited Nov 6 at 15:09
asked Nov 5 at 18:05
joanna
3732925
3732925
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
See Project.files(Object...) which states
You can pass any of the following types to this method:
...
A Task. Converted to the task's output files. The task is executed if the file collection is used as an input to another task.
So you can do:
task download(type: Download) {
...
into "$buildDir/download" // I'm guessing the config here
}
task unzip {
dependsOn download
inputs.dir "$buildDir/download"
outputs.dir "$buildDir/unzip"
doLast {
// use project.copy here instead of Copy task to delay the zipTree(...)
copy {
from zipTree("$buildDir/download/archive.zip")
into "$buildDir/unzip"
}
}
}
task dependency1 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency1.jar"
}
task dependency2 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency2.jar"
}
dependencies {
compile files(dependency1)
testCompile files(dependency2)
}
Note: if there's lots of jars in the zip you can do
['dependency1', 'dependency2', ..., 'dependencyN'].each {
tasks.create(it) {
dependsOn unzip
outputs.file "$buildDir/unzip/${it}.jar"
}
}
Managed to get the download working. Can't extract the files though, I think it's a build life cycle issue I don't full understand yet
– joanna
Nov 6 at 13:36
Perhaps you are forcing theConfiguration
to resolve() in the configuration phase instead of the execution phase. If this is the case then the tasks don't have a chance to execute. See Build Phases
– lance-java
Nov 7 at 8:25
I'm sure I do, I just don't really understand the trigger. In the sub project I have some local dependencies defined for a configuration like this:[name: '<some_dependency>']. Defining them this way forces the resolution in the configuration phase ?
– joanna
Nov 7 at 10:34
Whoops, I think it was my original solution which had build lifecycle issues. Please see my updated solution
– lance-java
Nov 7 at 11:41
add a comment |
up vote
0
down vote
I ended up using copy to force the unzip in the configuration phase
copy {
..
from zipTree(zipFile)
into outputDir
..
}
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
See Project.files(Object...) which states
You can pass any of the following types to this method:
...
A Task. Converted to the task's output files. The task is executed if the file collection is used as an input to another task.
So you can do:
task download(type: Download) {
...
into "$buildDir/download" // I'm guessing the config here
}
task unzip {
dependsOn download
inputs.dir "$buildDir/download"
outputs.dir "$buildDir/unzip"
doLast {
// use project.copy here instead of Copy task to delay the zipTree(...)
copy {
from zipTree("$buildDir/download/archive.zip")
into "$buildDir/unzip"
}
}
}
task dependency1 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency1.jar"
}
task dependency2 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency2.jar"
}
dependencies {
compile files(dependency1)
testCompile files(dependency2)
}
Note: if there's lots of jars in the zip you can do
['dependency1', 'dependency2', ..., 'dependencyN'].each {
tasks.create(it) {
dependsOn unzip
outputs.file "$buildDir/unzip/${it}.jar"
}
}
Managed to get the download working. Can't extract the files though, I think it's a build life cycle issue I don't full understand yet
– joanna
Nov 6 at 13:36
Perhaps you are forcing theConfiguration
to resolve() in the configuration phase instead of the execution phase. If this is the case then the tasks don't have a chance to execute. See Build Phases
– lance-java
Nov 7 at 8:25
I'm sure I do, I just don't really understand the trigger. In the sub project I have some local dependencies defined for a configuration like this:[name: '<some_dependency>']. Defining them this way forces the resolution in the configuration phase ?
– joanna
Nov 7 at 10:34
Whoops, I think it was my original solution which had build lifecycle issues. Please see my updated solution
– lance-java
Nov 7 at 11:41
add a comment |
up vote
0
down vote
See Project.files(Object...) which states
You can pass any of the following types to this method:
...
A Task. Converted to the task's output files. The task is executed if the file collection is used as an input to another task.
So you can do:
task download(type: Download) {
...
into "$buildDir/download" // I'm guessing the config here
}
task unzip {
dependsOn download
inputs.dir "$buildDir/download"
outputs.dir "$buildDir/unzip"
doLast {
// use project.copy here instead of Copy task to delay the zipTree(...)
copy {
from zipTree("$buildDir/download/archive.zip")
into "$buildDir/unzip"
}
}
}
task dependency1 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency1.jar"
}
task dependency2 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency2.jar"
}
dependencies {
compile files(dependency1)
testCompile files(dependency2)
}
Note: if there's lots of jars in the zip you can do
['dependency1', 'dependency2', ..., 'dependencyN'].each {
tasks.create(it) {
dependsOn unzip
outputs.file "$buildDir/unzip/${it}.jar"
}
}
Managed to get the download working. Can't extract the files though, I think it's a build life cycle issue I don't full understand yet
– joanna
Nov 6 at 13:36
Perhaps you are forcing theConfiguration
to resolve() in the configuration phase instead of the execution phase. If this is the case then the tasks don't have a chance to execute. See Build Phases
– lance-java
Nov 7 at 8:25
I'm sure I do, I just don't really understand the trigger. In the sub project I have some local dependencies defined for a configuration like this:[name: '<some_dependency>']. Defining them this way forces the resolution in the configuration phase ?
– joanna
Nov 7 at 10:34
Whoops, I think it was my original solution which had build lifecycle issues. Please see my updated solution
– lance-java
Nov 7 at 11:41
add a comment |
up vote
0
down vote
up vote
0
down vote
See Project.files(Object...) which states
You can pass any of the following types to this method:
...
A Task. Converted to the task's output files. The task is executed if the file collection is used as an input to another task.
So you can do:
task download(type: Download) {
...
into "$buildDir/download" // I'm guessing the config here
}
task unzip {
dependsOn download
inputs.dir "$buildDir/download"
outputs.dir "$buildDir/unzip"
doLast {
// use project.copy here instead of Copy task to delay the zipTree(...)
copy {
from zipTree("$buildDir/download/archive.zip")
into "$buildDir/unzip"
}
}
}
task dependency1 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency1.jar"
}
task dependency2 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency2.jar"
}
dependencies {
compile files(dependency1)
testCompile files(dependency2)
}
Note: if there's lots of jars in the zip you can do
['dependency1', 'dependency2', ..., 'dependencyN'].each {
tasks.create(it) {
dependsOn unzip
outputs.file "$buildDir/unzip/${it}.jar"
}
}
See Project.files(Object...) which states
You can pass any of the following types to this method:
...
A Task. Converted to the task's output files. The task is executed if the file collection is used as an input to another task.
So you can do:
task download(type: Download) {
...
into "$buildDir/download" // I'm guessing the config here
}
task unzip {
dependsOn download
inputs.dir "$buildDir/download"
outputs.dir "$buildDir/unzip"
doLast {
// use project.copy here instead of Copy task to delay the zipTree(...)
copy {
from zipTree("$buildDir/download/archive.zip")
into "$buildDir/unzip"
}
}
}
task dependency1 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency1.jar"
}
task dependency2 {
dependsOn unzip
outputs.file "$buildDir/unzip/dependency2.jar"
}
dependencies {
compile files(dependency1)
testCompile files(dependency2)
}
Note: if there's lots of jars in the zip you can do
['dependency1', 'dependency2', ..., 'dependencyN'].each {
tasks.create(it) {
dependsOn unzip
outputs.file "$buildDir/unzip/${it}.jar"
}
}
edited Nov 7 at 11:45
answered Nov 5 at 20:35
lance-java
15.8k12858
15.8k12858
Managed to get the download working. Can't extract the files though, I think it's a build life cycle issue I don't full understand yet
– joanna
Nov 6 at 13:36
Perhaps you are forcing theConfiguration
to resolve() in the configuration phase instead of the execution phase. If this is the case then the tasks don't have a chance to execute. See Build Phases
– lance-java
Nov 7 at 8:25
I'm sure I do, I just don't really understand the trigger. In the sub project I have some local dependencies defined for a configuration like this:[name: '<some_dependency>']. Defining them this way forces the resolution in the configuration phase ?
– joanna
Nov 7 at 10:34
Whoops, I think it was my original solution which had build lifecycle issues. Please see my updated solution
– lance-java
Nov 7 at 11:41
add a comment |
Managed to get the download working. Can't extract the files though, I think it's a build life cycle issue I don't full understand yet
– joanna
Nov 6 at 13:36
Perhaps you are forcing theConfiguration
to resolve() in the configuration phase instead of the execution phase. If this is the case then the tasks don't have a chance to execute. See Build Phases
– lance-java
Nov 7 at 8:25
I'm sure I do, I just don't really understand the trigger. In the sub project I have some local dependencies defined for a configuration like this:[name: '<some_dependency>']. Defining them this way forces the resolution in the configuration phase ?
– joanna
Nov 7 at 10:34
Whoops, I think it was my original solution which had build lifecycle issues. Please see my updated solution
– lance-java
Nov 7 at 11:41
Managed to get the download working. Can't extract the files though, I think it's a build life cycle issue I don't full understand yet
– joanna
Nov 6 at 13:36
Managed to get the download working. Can't extract the files though, I think it's a build life cycle issue I don't full understand yet
– joanna
Nov 6 at 13:36
Perhaps you are forcing the
Configuration
to resolve() in the configuration phase instead of the execution phase. If this is the case then the tasks don't have a chance to execute. See Build Phases– lance-java
Nov 7 at 8:25
Perhaps you are forcing the
Configuration
to resolve() in the configuration phase instead of the execution phase. If this is the case then the tasks don't have a chance to execute. See Build Phases– lance-java
Nov 7 at 8:25
I'm sure I do, I just don't really understand the trigger. In the sub project I have some local dependencies defined for a configuration like this:[name: '<some_dependency>']. Defining them this way forces the resolution in the configuration phase ?
– joanna
Nov 7 at 10:34
I'm sure I do, I just don't really understand the trigger. In the sub project I have some local dependencies defined for a configuration like this:[name: '<some_dependency>']. Defining them this way forces the resolution in the configuration phase ?
– joanna
Nov 7 at 10:34
Whoops, I think it was my original solution which had build lifecycle issues. Please see my updated solution
– lance-java
Nov 7 at 11:41
Whoops, I think it was my original solution which had build lifecycle issues. Please see my updated solution
– lance-java
Nov 7 at 11:41
add a comment |
up vote
0
down vote
I ended up using copy to force the unzip in the configuration phase
copy {
..
from zipTree(zipFile)
into outputDir
..
}
add a comment |
up vote
0
down vote
I ended up using copy to force the unzip in the configuration phase
copy {
..
from zipTree(zipFile)
into outputDir
..
}
add a comment |
up vote
0
down vote
up vote
0
down vote
I ended up using copy to force the unzip in the configuration phase
copy {
..
from zipTree(zipFile)
into outputDir
..
}
I ended up using copy to force the unzip in the configuration phase
copy {
..
from zipTree(zipFile)
into outputDir
..
}
answered Nov 8 at 8:51
joanna
3732925
3732925
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53159834%2fgradle-build-resolve-dependencies-from-downloaded-archive%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password