In my all projects I have build.gradle and it has buildscript with repositories, spring version & information
For security scanning, we are creating new job in Teamcity where it need all project dependencies in one folder, so it can scan all of them (instead of final build - for some reason).
I am trying to create a temporary file in TC job with name dependencies.gradle like below
apply from: 'build.gradle'
task copyDependencies(type: Copy) {
from configurations.default
into 'build/dependencies'
}
Running it with ./gradlew --build-file=dependencies.gradle copyDependencies
But this is not working as it is not getting repositories & other info from main build.gradle buildscript.
I am just trying to avoid adding this task in all projects for just scanning job. Is there any better way?
I am unable to reproduce an issue. I just tried your dependencies.gradle file and the copyDependencies task worked. In my build.gradle I have something simple:
Personally, I implement similar Jenkins-only content using init scripts. You can include them on the command line using -I or put them in ~/.gradle/init.d. For example:
allprojects {
pluginManager.withPlugin( 'java' ) {
task copyDependencies( type: Copy ) {
from configurations.default
into 'build/dependencies'
}
}
}
The buildscript { repositories { ... } } only apply to the classpath used to execute the gradle build script itself and are not related to the resolution of the dependencies of configurations.default. You must have an additional repositories { ... } block somewhere outside buildscript { ... } (or in a plugin?).
As far as I know what you have should work. Are you getting an error? What is it?
Sorry my bad again, i renamed company names & missed that, it was complaining about the plugin com.test.repositories which defined in the main build.gradle
artefact_repo_urls are defined in gradle.properties and there is no issue if I run with build.gradle, looks like it plugins defined in the test:test-gradle-plugin in buildscript is not visible to dependencies.gradle.