Define things in the init.gradle


(Willie) #1

this block of code

buildscript {
    dependencies {
        classpath 'com.me.mystyff-jvm:+'
        classpath "com.linkedin.pygradle:pygradle-plugin:0.+"
    }
}

adding this to the build script works just fine. but when i move it to the wrapper/init.d/init.gradle i get errors about not being able to resolve the dependencies. I tried searching thru issues and see all kinds of circular reports about this sort of thing, Can i put this type of piece into the init.gradle or not?


(Chris Doré) #2

Try wrapping your code in allprojects {}


(Willie) #3

That’s what I was doing. I was wrapping it in I believe gradle.allprojects It wasn’t working. I’ll track down the exact syntax I tried in a few hours


(Willie) #4

I should mention defining the buildscript.repositories in the init is working fine. It’s the dependencies that isn’t working. I’m curious if that is possible in the init.gradle


(Chris Doré) #5

Sorry, I missed the part in your original post about the dependency resolution problems. Did you add any repositories to the buildscript block, I don’t see them in your example?

Yes, you should be able to add the dependencies from init.gradle.


(Willie) #6

Heres the init. When the buildscript portion above is in the build.gradle of the project, everything works fine.

gradle.projectsLoaded {
    rootProject.allprojects {
        buildscript {
            repositories {
                mavenLocal()
                maven { url "https://artifactorytest.mycompany.com/artifactory/jvm-transitive" }
                maven { url "https://artifactorytest.mycompany.com/artifactory/gradle-plugins-snapshot" }
                maven { url "https://artifactorytest.mycompany.com/artifactory/gradle-plugins" }
            }
        }
    }
}

but when i do this

gradle.projectsLoaded {
    rootProject.allprojects {
        buildscript {
            repositories {
                mavenLocal()
                maven { url "https://artifactorytest.mycompany.com/artifactory/jvm-transitive" }
                maven { url "https://artifactorytest.mycompany.com/artifactory/gradle-plugins-snapshot" }
                maven { url "https://artifactorytest.mycompany.com/artifactory/gradle-plugins" }
            }
           dependencies {
            classpath 'com.me.mystyff-jvm:+'
            classpath "com.linkedin.pygradle:pygradle-plugin:0.+"
          }
        }
    }
}

i started getting the aforementioned class not found errors.


(Chris Doré) #7

If I take out your company specifics and add a repository that is capable of resolving pygradle-plugin, then everything is working.

init.gradle:

gradle.projectsLoaded {
    rootProject.allprojects {
        buildscript {
            repositories {
                jcenter()
            }
           dependencies {
            classpath "com.linkedin.pygradle:pygradle-plugin:0.+"
          }
        }
    }
}

build.gradle:

apply plugin: 'com.linkedin.python-sdist'

Are you getting class not found errors or dependency resolution errors?