Custom Repository Enable/Disable during Execution Phase

gradle-core
plugins

(Siva Jeganathan) #1

Any suggestions for Enabling / Disabling Custom Artifactory during Execution phase ?

Hi I am using Java for Plugin Development. I am looking to Enable/Disable “Custom Artifactory” during execution phase. Say 2 tasks EnableInternalRepo and DisableInternalRepo

REASON for Runtime Config: I have 2-5 Artifactories. User should be able to switch between these artifactories at will

I am able to add Maven repo using something similar to below code in my Task Config part.

public class RepoConfig extends DefaultTask {
public RepoConfig() {
    Action<MavenArtifactRepository> customRepo = new Action<MavenArtifactRepository>() {
          @Override
          public void execute(MavenArtifactRepository repo) {
              repo.setName("customRepo");
              repo.setUrl("https://customRepo.com/artifactory/customRepo");
              repo.getCredentials().setUsername("xxxx@yyyy.com");
              repo.getCredentials().setPassword("ppppp");
          }
      };
}
}

However, I don’t know how to disable it / re-enable it after configuring in “Task Config” phase.

I tried adding above code inside TaskAction method (Execution Phase). But I am not able to enable/disable repo.