2016-11-09 3 views
0

In Maven gibt es die Datei settings.xml, in der ich Repositories konfiguriere (wie das Maven-Repository auf einem Sonatype-Nexus-Server). In meinem Gradle-Projekt wird die URL des Maven-Repositories direkt in meiner build.gradle Datei konfiguriert.Best Practice in Gradle, um Maven-Repositories global zu konfigurieren

Was ist Best Practice in Gradle, um Repositories global und außerhalb der Build-Datei zu konfigurieren?

Antwort

0

habe ich folgendes in %GRADLE_USER_HOME%/gradle.properties

nexus.user=somecoolguy 
nexus.password=guessme 

Dann benutze ich diese Schnipsel

allprojects { 
    repositories { 
     def repoUrls = [ 
      'https://mynexus:8081/nexus/content/groups/foo', 
      'https://mynexus:8081/nexus/content/groups/bar', 
      'https://mynexus:8081/nexus/content/groups/baz' 
     } 
     repoUrls.each { String repoUrl -> 
      maven { 
       url repoUrl 
       credentials { 
        username project.properties['nexus.user'] 
        password project.properties['nexus.password'] 
       } 
      } 
     } 
    } 
} 

Sie easliy die Schnipsel in eine custom plugin verwandeln konnte und es vielleicht zu

  1. Nutzung verbessern ein verschlüsseltes Passwort
  2. Nicht bestanden, wenn project.hasProperty('nexus.user') false zurückgibt
Verwandte Themen