Adding repositories to the buildscript


(The Temportalist) #1

Hey all. I have recently started working on my (first) gradle plugin. Yay!
Anyway, I am hoping someone can point me in the right direction. I am attempting to add a maven repository and dependency to the buildscript during the Plugin apply method.

maven { name = "forge" url = "http://files.minecraftforge.net/maven" }

project.getBuildscript().getRepositories(); // add project.getBuildscript().getDependencies().add("classpath", "net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT"); project.getPlugins().apply("net.minecraftforge.gradle.forge");

Is this something that can be done? And if so, I am unsure of how to implement the DefaultMavenArtifactRepository in the project.getBuildscript().getRepositories().add(…) function.

Source code can be found at: https://github.com/TheTemportalist/AutomataGradlePlugin/blob/cf5c94167fcb3538c3b20c997ea0a0c4c7075d66/src/main/java/temportalist/automata/AutomataGradlePlugin.java#L39


(Dimitar Dimitrov) #2

You can do that only in an init script plugin (applied to an instance of Gradle). There are examples how to do it - just search.