diff --git a/.travis.yml b/.travis.yml index f7ddeb1..e05e64d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,16 @@ language: groovy -install: - - ./gradlew -S clean --info +sudo: true + +install: true script: - - ./gradlew -S build gradleTest --info + - ./gradlew -S clean build --console=plain --info jdk: - - oraclejdk7 - oraclejdk8 - - openjdk7 - - openjdk6 os: - linux -env: - - TERM=dumb - -#after_success: ./gradlew coveralls -PbintrayUser= -PbintrayApiKey diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 8d2a941..0815448 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,34 +1,49 @@ = CHANGELOG +:issue: link:https://github.com/ysb33r/ivypot-gradle-plugin/issues/ -== 0.4 - Roadmap +== 0.5 - Roadmap -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/12[Issue #12] - Make default layout 'gradle'. +=== Bugs + +* {issue}28[#28] - Unable to create task extending org.ysb33r.gradle.ivypot.OfflineRepositorySync + +=== Breaking changes + +* Minimum supported version is Gradle 2.8 + +=== Compatibility + +* Gradle compatibility tested 2.8 - 4.2 + +== 0.4 + +* {issue}12[#12] - Make default layout 'gradle'. == 0.3.7 -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/10[Issue #11] - Patterns for writing artifacts is now configurable. +* {issue}11[#11] - Patterns for writing artifacts is now configurable. == 0.3.6 -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/10[Issue #10] - Fixes issues that was suppose to be fixed by https://github.com/ysb33r/ivypot-gradle-plugin/issues/8[Issue #9]. +* {issue}10[#10] - Fixes issues that was suppose to be fixed by {issue}9[#9]. * Compatibility check up to Gradle 2.11 == 0.3.5 -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/8[Issue #9] - Cannot use pattern-based Ivy Resolver since Gradle 2.3. +* {issue}9[#9] - Cannot use pattern-based Ivy Resolver since Gradle 2.3. == 0.3.4 -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/8[Issue #8] - Transitive dependencies are not copied to local repository. +* {issue}8[#8] - Transitive dependencies are not copied to local repository. == 0.3.3 (Avoid this release) -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/7[Issue #7] - When using two `OfflineRepositorySync` tasks, the build fails. +* {issue}7[#7] - When using two `OfflineRepositorySync` tasks, the build fails. == 0.3.2 -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/5[Issue #5] - Don't mix cache data with artifacts. -* https://github.com/ysb33r/ivypot-gradle-plugin/issues/6[Issue #6] - Specifying ivy repositories with only a URL does not work. +* {issue}5[#5] - Don't mix cache data with artifacts. +* {issue}6[#6] - Specifying ivy repositories with only a URL does not work. == 0.3.1 diff --git a/README.adoc b/README.adoc index 922eff1..89f6642 100644 --- a/README.adoc +++ b/README.adoc @@ -1,4 +1,5 @@ = IvyPot - A Gradle plugin for Off-line Repositories +:revnumber: 0.5 Not all development teams have the luxury of relying on Maven Central, Bintray for day to day development. Some of them are still fortunate to proxy public repositories via in-house Artifactory or Nexus instances. Others have even more @@ -6,8 +7,11 @@ strict requirements including the ability to be able to build an isolated enviro for public dependencies, including transitive dependencies, to be downloaded in a controlled manner and the internal security processes to be applied to the binary files before committing them to an internal storage area. +As from 0.5 the minimum supported Gradle version in 2.8. + == Previous versions +* https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_4_0[Release 0.4.0] * https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_3_7[Release 0.3.7] * https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_3_6[Release 0.3.6] * https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_3_5[Release 0.3.5] @@ -17,7 +21,18 @@ security processes to be applied to the binary files before committing them to a == Adding the plugin -[source,groovy] +.build.gradle +[source,groovy,subs="+attributes"] +---- +plugins { + id 'org.ysb33r.ivypot' version '{revnumber}' +} +---- + +Or for special cases you might want to do + +.build.gradle +[source,groovy,subs="+attributes"] ---- buildscript { repositories { @@ -26,16 +41,14 @@ buildscript { } } dependencies { - classpath 'org.ysb33r.gradle:ivypot:0.3.2' + classpath 'org.ysb33r.gradle:ivypot:{revnumber}' } } apply plugin : 'org.ysb33r.ivypot' ---- -or if you use Gradle 2.1+ - -If you are in a restricted environment, you might want to use approach number #1 and conditionally add the remote reference +If you are in a restricted environment, you might want to use the second approach and conditionally add the remote reference to work only when you are in a non-restricted environment. i.e. [source,groovy] @@ -49,12 +62,7 @@ to work only when you are in a non-restricted environment. i.e. } ---- -[source,groovy] ----- -plugins { - id 'org.ysb33r.ivypot' version '0.4' -} ----- +You might also consider using link:https://docs.gradle.org/current/userguide/plugins.html#customPluginRepositories[pluginManagement] in `settings.gradle` for this case. == Defining Remote Repositories diff --git a/appveyor.yml b/appveyor.yml index 6bd0eb7..6d9e573 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,10 +4,10 @@ build: verbosity: detailed build_script: - - gradlew.bat -PTRAVIS_CI=1 assemble --info --no-daemon -PbintrayUserName -PbintrayApiKey + - gradlew.bat assemble --info --no-daemon test_script: - - gradlew.bat check gradleTest -PTRAVIS_CI=1 --info --no-daemon -PbintrayUserName -PbintrayApiKey + - gradlew.bat build --info --no-daemon branches: only: @@ -17,9 +17,7 @@ branches: environment: matrix: - - JAVA_HOME: C:\Program Files\Java\jdk1.7.0 - JAVA_HOME: C:\Program Files\Java\jdk1.8.0 - - JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0 - JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0 matrix: diff --git a/build.gradle b/build.gradle index 109f503..cb9b5fb 100644 --- a/build.gradle +++ b/build.gradle @@ -14,64 +14,56 @@ // PLEASE NOTE: Integration Tests and Gradle Compatibility tests download a number of files. -buildscript { - repositories { - jcenter() - mavenLocal() - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "com.gradle.publish:plugin-publish-plugin:0.9.0" - classpath 'org.ysb33r.gradle:gradletest:0.5.5' - classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1' - } -} -apply plugin : 'groovy' -apply plugin : 'maven' -apply plugin : 'com.gradle.plugin-publish' -apply plugin : 'com.github.hierynomus.license' -apply plugin : 'org.ysb33r.gradletest' +plugins { + id 'groovy' + id 'maven' + id 'com.gradle.plugin-publish' version '0.9.7' + id 'com.github.hierynomus.license' version '0.12.1' + id 'org.ysb33r.gradletest' version '1.0' +} apply from: 'gradle/integration-tests.gradle' -version = '0.4' +version = '0.5' group = 'org.ysb33r.gradle' sourceCompatibility = 1.6 targetCompatibility = 1.6 +ext { + groovyLongVer = GroovySystem.version + groovyShortVer = GroovySystem.version.replaceAll(/\.\d+$/,'') -plugins.withType(JavaPlugin) { - - project.tasks.withType(JavaCompile) { task -> - task.sourceCompatibility = project.sourceCompatibility - task.targetCompatibility = project.targetCompatibility + ivyJar = fileTree("${gradle.gradleHomeDir}/lib/plugins") { + include 'ivy*.jar' } +} - project.tasks.withType(GroovyCompile) { task -> - task.sourceCompatibility = project.sourceCompatibility - task.targetCompatibility = project.targetCompatibility +task foo { + doLast { + println ivyJar.files } } - repositories { jcenter() } dependencies { + compile 'org.ysb33r.gradle:grolifant:0.3' compile gradleApi() compile localGroovy() - testCompile 'org.spockframework:spock-core:1.0-groovy-2.3', { + testCompile "org.spockframework:spock-core:1.1-groovy-${groovyShortVer}", { exclude module : 'groovy-all' } - testCompile( 'com.athaydes:spock-reports:1.2.10' ) { - transitive = false // this avoids affecting your version of Groovy/Spock - } testCompile 'org.slf4j:slf4j-api:1.7.13' testCompile 'org.slf4j:slf4j-simple:1.7.13' + + testRuntime ivyJar +} + +test { + systemProperties DONT_LOOK_FOR_IVY_JAR : 1 } integrationTest { @@ -89,8 +81,8 @@ license { mapping { groovy ='DOUBLESLASH_STYLE' } - ext.year = '2013-2015' - excludes(['**/*.ad', '**/*.asciidoc', '**/*.adoc', '**/*.md','**/*.properties']) + ext.year = '2013-2017' + excludes(['**/*.ad', '**/*.asciidoc', '**/*.adoc', '**/*.md','**/*.properties','**/*CompatibilitySpec.groovy']) } pluginBundle { @@ -115,22 +107,27 @@ pluginBundle { } publishPlugins { + group 'release' onlyIf { !version.endsWith("SNAPSHOT") } -} - -gradleLocations { - downloadToGradleUserHome = true + mustRunAfter build } gradleTest { - versions '2.0' - versions '2.2' - versions '2.3' - versions '2.4' - versions '2.8' - versions '2.10' - versions '2.12', '2.13-rc-1' + versions '2.8', '2.10' + versions '2.12', '2.14.1' + versions '3.0', '3.1', '3.5' + versions '4.0', '4.1', '4.2' inputs.files jar inputs.dir file('gradleTest') + + beforeTest { + println " ${it.name}" + } +} + +task release { + group 'release' + description 'Life-cycle task for relasing the plugin' + dependsOn build, publishPlugins } diff --git a/gradle/integration-tests.gradle b/gradle/integration-tests.gradle index 21943c7..37e560d 100644 --- a/gradle/integration-tests.gradle +++ b/gradle/integration-tests.gradle @@ -12,16 +12,20 @@ configurations { sourceSets { integrationTest { - java.srcDir file("src/integTest/java") - groovy.srcDir file("src/integTest/groovy") - resources.srcDir file("src/integTest/resources") + java.srcDir file('src/integTest/java') + groovy.srcDir file('src/integTest/groovy') + resources.srcDir file('src/integTest/resources') compileClasspath = sourceSets.main.output + configurations.integrationTestCompile runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime } } task integrationTest(type: Test, dependsOn: jar) { - testClassesDir = sourceSets.integrationTest.output.classesDir + if(GradleVersion.current() < GradleVersion.version('4.0')) { + testClassesDir = sourceSets.integrationTest.output.classesDir + } else { + testClassesDirs = sourceSets.integrationTest.output.classesDirs + } classpath = sourceSets.integrationTest.runtimeClasspath mustRunAfter test } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 2322723..05ef575 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f89bc7c..86c6b99 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 22 14:13:52 BST 2015 +#Fri Sep 29 21:31:19 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..9d82f78 100755 --- a/gradlew +++ b/gradlew @@ -42,11 +42,6 @@ case "`uname`" in ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -114,6 +109,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/src/gradleTest/basicTest/build.gradle b/src/gradleTest/basicTest/build.gradle index 327f29e..90ef09b 100644 --- a/src/gradleTest/basicTest/build.gradle +++ b/src/gradleTest/basicTest/build.gradle @@ -1,9 +1,3 @@ -buildscript { - dependencies { - classpath 'org.ysb33r.gradle:ivypot:%%VERSION%%' - } -} - apply plugin : 'org.ysb33r.ivypot' configurations { diff --git a/src/integrationTest/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncIntegrationSpec.groovy b/src/integrationTest/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncIntegrationSpec.groovy index eb6d70e..5b812f6 100644 --- a/src/integrationTest/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncIntegrationSpec.groovy +++ b/src/integrationTest/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncIntegrationSpec.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/IvyXml.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/IvyXml.groovy index 0b6cdf1..a9a6795 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/IvyXml.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/IvyXml.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPlugin.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPlugin.groovy index 6597fdf..a78fb08 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPlugin.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPlugin.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -14,14 +14,23 @@ package org.ysb33r.gradle.ivypot +import org.gradle.api.GradleException import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.util.GradleVersion /** * @author Schalk W. Cronjé */ class OfflineRepositoryPlugin implements Plugin { + + final static String MINIMUM_GRADLE = '2.8' + void apply(Project project) { + + if(GradleVersion.current() < GradleVersion.version(MINIMUM_GRADLE)) { + throw new GradleException("Ivypot can only be used with Gradle ${MINIMUM_GRADLE} or later") + } project.tasks.create 'syncRemoteRepositories', OfflineRepositorySync } } diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySync.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySync.groovy index 2144ab3..66e4395 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySync.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySync.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -335,6 +335,5 @@ class OfflineRepositorySync extends DefaultTask { new DefaultRepositoryHandler(new BaseRepositoryFactory(), instantiator) } - @PackageScope - static boolean DONT_LOOK_FOR_IVY_JAR = false + static private boolean DONT_LOOK_FOR_IVY_JAR = System.getProperty('DONT_LOOK_FOR_IVY_JAR') } diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/BaseRepositoryFactory.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/BaseRepositoryFactory.groovy index 7eab676..e40fde5 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/BaseRepositoryFactory.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/BaseRepositoryFactory.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -14,6 +14,7 @@ package org.ysb33r.gradle.ivypot.internal +import org.gradle.api.GradleException import org.gradle.api.artifacts.repositories.FlatDirectoryArtifactRepository import org.gradle.api.artifacts.repositories.IvyArtifactRepository import org.gradle.api.artifacts.repositories.MavenArtifactRepository @@ -32,6 +33,10 @@ class BaseRepositoryFactory implements org.gradle.api.internal.artifacts.BaseRep new MavenCentral() } + MavenArtifactRepository createGoogleRepository() { + throw new GradleException('Google repositories are not supported as yet. Register your interest at https://github.com/ysb33r/ivypot-gradle-plugin/issues/22') + } + @Override MavenArtifactRepository createMavenRepository() { new MavenRepository() diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/Credentials.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/Credentials.groovy index 66cd843..3cc1756 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/Credentials.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/Credentials.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/IvyRepository.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/IvyRepository.groovy index 4221015..b292bc1 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/IvyRepository.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/IvyRepository.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -14,14 +14,17 @@ package org.ysb33r.gradle.ivypot.internal -import groovy.transform.TypeChecked +import groovy.transform.CompileDynamic +import groovy.transform.CompileStatic +import org.gradle.api.Action import org.gradle.api.artifacts.repositories.IvyArtifactRepository import org.gradle.api.artifacts.repositories.IvyArtifactRepositoryMetaDataProvider +import org.gradle.api.artifacts.repositories.RepositoryLayout import org.ysb33r.gradle.ivypot.IvyXml /** - * @author Schalk W. Cronjé */ +@CompileStatic class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits { String artifactPattern @@ -41,7 +44,7 @@ class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits { */ @Override void artifactPattern(String pattern) { - this.artifactPattern += pattern + this.artifactPattern+= pattern } /** @@ -66,7 +69,6 @@ class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits { * @param layoutName The name of the layout to use. */ @Override - @TypeChecked void layout(final String layoutName) { final String namespace = 'org.gradle.api.internal.artifacts.repositories.layout.' String repositoryLayoutName @@ -93,7 +95,7 @@ class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits { } } - repositoryLayout = layoutClass.newInstance() + setLayoutClass(layoutClass) } /** @@ -146,11 +148,23 @@ class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits { @Override void layout(String layoutName, Closure config) { layout(layoutName) - def cfg = config.clone() + Closure cfg = (Closure)(config.clone()) cfg.delegate = repositoryLayout cfg() } + /** Specifies how the items of the repository are organized. + * + * @param layoutName The name of the layout to use. + * @param action The action used to configure the layout. Takes a {@code RepositoryLayout} as parameter. + * + * @since 0.5 + */ + void layout(String layoutName, Action action) { + layout(layoutName) + action.execute(repositoryLayout) + } + /** * Returns the meta-data provider used when resolving artifacts from this repository. The provider is responsible for locating and interpreting the meta-data * for the modules and artifacts contained in this repository. Using this provider, you can fine tune how this resolution happens. @@ -173,8 +187,8 @@ class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits { throw new UnsupportedOperationException('layout has not seen set for Ivy repository') } - def patterns = new PatternBasedResolver() - repositoryLayout.apply(url, patterns) + PatternBasedResolver patterns = new PatternBasedResolver() + applyPatterns(patterns) String ret = "" patterns.ivyPatterns.each { @@ -186,5 +200,24 @@ class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits { ret += '' } - private def repositoryLayout +// void setMetadataSupplier(Class aClass) { +// throw new GradleException("Metadata is not implemented. If this is a requirement for your use case then register your interest at https://github.com/ysb33r/ivypot-gradle-plugin/issues/23") +// } +// +// void setMetadataSupplier(Class aClass, Action action) { +// throw new GradleException("Metadata is not implemented. If this is a requirement for your use case then register your interest at https://github.com/ysb33r/ivypot-gradle-plugin/issues/23") +// } + + @CompileDynamic + private void applyPatterns(final PatternBasedResolver patterns) { + repositoryLayout.apply(url, patterns) + } + + @CompileDynamic + private void setLayoutClass(Class layoutClass) { + repositoryLayout = layoutClass.newInstance() + } + + private RepositoryLayout repositoryLayout + } diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/JCenter.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/JCenter.groovy index f540c76..bea7849 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/JCenter.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/JCenter.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenCentral.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenCentral.groovy index 54fcda5..d2c0240 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenCentral.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenCentral.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenLocal.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenLocal.groovy index 57d4410..9e5e464 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenLocal.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenLocal.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenRepository.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenRepository.groovy index 328d58c..1f6c9ae 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenRepository.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/MavenRepository.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -52,6 +52,20 @@ class MavenRepository implements MavenArtifactRepository, IvyXml, RepositoryTrai artifactUrls.addAll(urls as List) } + /** + * Sets the additional URLs to use to find artifact files. Note that these URLs are not used to find POM files. + * + *

The provided values are evaluated as per {@link org.gradle.api.Project#uri(Object)}. This means, for example, you can pass in a {@code File} object, or a relative path to be evaluated + * relative to the project directory. + * + * @param urls The URLs. + */ +// @Override + void setArtifactUrls(Set urls) { + artifactUrls.clear() + artifactUrls.addAll(urls) + } + /** * Sets the additional URLs to use to find artifact files. Note that these URLs are not used to find POM files. * diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolver.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolver.groovy index 8029cac..3ccd363 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolver.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolver.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -14,7 +14,6 @@ package org.ysb33r.gradle.ivypot.internal -import org.apache.commons.lang.NotImplementedException import org.gradle.api.internal.artifacts.repositories.resolver.IvyResourcePattern import org.gradle.api.internal.artifacts.repositories.resolver.M2ResourcePattern import org.gradle.api.internal.artifacts.repositories.resolver.ResourcePattern diff --git a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/RepositoryTraits.groovy b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/RepositoryTraits.groovy index d960c0a..192d33b 100644 --- a/src/main/groovy/org/ysb33r/gradle/ivypot/internal/RepositoryTraits.groovy +++ b/src/main/groovy/org/ysb33r/gradle/ivypot/internal/RepositoryTraits.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -15,11 +15,17 @@ package org.ysb33r.gradle.ivypot.internal import groovy.transform.CompileDynamic +import groovy.transform.CompileStatic +import org.gradle.api.Action +import org.gradle.api.GradleException +import org.gradle.api.artifacts.repositories.AuthenticationContainer import org.gradle.api.artifacts.repositories.PasswordCredentials +import org.ysb33r.gradle.olifant.UriUtils /** - * @author Schalk W. Cronjé + * */ +@CompileStatic trait RepositoryTraits { /** * The base URL of this repository. This URL is used to find both POMs and artifact files. You can add additional URLs to use to look for artifact files, such as jars, using {@link @@ -28,7 +34,7 @@ trait RepositoryTraits { * @return The URL. */ URI getUrl() { - this.url.toString().toURI() + UriUtils.urize(this.url) } /** @@ -44,6 +50,21 @@ trait RepositoryTraits { this.url = url_ } + /** + * Sets the base URL of this repository. This URL is used to find both POMs and artifact files. You can add additional URLs to use to look for artifact files, such as jars, using {@link + * # setArtifactUrls ( Iterable )}. + * + *

The provided value is evaluated as per {@link org.gradle.api.Project#uri(Object)}. This means, for example, you can pass in a {@code File} object, or a relative path to be evaluated relative + * to the project directory. + * + * @param uri The base URI. + * + * @since 0.5 + */ + void setUrl(URI uri_) { + this.url = uri_ + } + /** * Sets the base URL of this repository. This URL is used to find both POMs and artifact files. You can add additional URLs to use to look for artifact files, such as jars, using {@link * # setArtifactUrls ( Iterable )}. @@ -79,13 +100,49 @@ trait RepositoryTraits { * } * @endcode */ - @CompileDynamic void credentials(Closure closure) { - def cfg = closure.clone() + Closure cfg = (Closure)(closure.clone()) cfg.delegate = this.credentials cfg() } + /** Configure the credientials for this repository using the supplied action. + * + * @param action + * + * @since 0.5 + */ + void credentials(Action action) { + action.execute(this.credentials) + } + + /** Access to the credentials class that is in use. + * + * @param aClass + * @return + * + * @since 0.5 + */ + def T getCredentials(Class aClass) { + if (this.credentials instanceof T) { + return (T)(this.credentials) + } else { + throw new IllegalArgumentException("${Credentials.class.name} cannot be converted to ${aClass.name}") + } + } + + /** + * + * @param aClass + * @param action + * + * @since 0.5 + */ + def void credentials(Class aClass, Action action) { + T creds = getCredentials(aClass) + action.execute(creds) + } + /** * Returns the name for this repository. A name must be unique amongst a repository set. A default name is provided for the repository if none * is provided. @@ -112,6 +169,15 @@ trait RepositoryTraits { this.name = name } + void authentication(Action action) { + throw new GradleException("Authentication containers are not implemented. If this is a requirement for your use case then register your interest at https://github.com/ysb33r/ivypot-gradle-plugin/issues/24") + } + + AuthenticationContainer getAuthentication() { + throw new GradleException("Authentication containers are not implemented. If this is a requirement for your use case then register your interest at https://github.com/ysb33r/ivypot-gradle-plugin/issues/24") + } + + private String name private Object url private Credentials credentials = new Credentials() diff --git a/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPluginSpec.groovy b/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPluginSpec.groovy index bd7b81b..b1cfbd1 100644 --- a/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPluginSpec.groovy +++ b/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositoryPluginSpec.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details @@ -24,7 +24,7 @@ import spock.lang.Specification class OfflineRepositoryPluginSpec extends Specification { void setupSpec() { - OfflineRepositorySync.DONT_LOOK_FOR_IVY_JAR = true +// OfflineRepositorySync.DONT_LOOK_FOR_IVY_JAR = true } def "Can the plugin be applied"() { diff --git a/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncSpec.groovy b/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncSpec.groovy index 778c104..39c3694 100644 --- a/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncSpec.groovy +++ b/src/test/groovy/org/ysb33r/gradle/ivypot/OfflineRepositorySyncSpec.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details diff --git a/src/test/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolverSpec.groovy b/src/test/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolverSpec.groovy index 8966ca1..8740fa9 100644 --- a/src/test/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolverSpec.groovy +++ b/src/test/groovy/org/ysb33r/gradle/ivypot/internal/PatternBasedResolverSpec.groovy @@ -1,6 +1,6 @@ // // ============================================================================ -// (C) Copyright Schalk W. Cronje 2013-2015 +// (C) Copyright Schalk W. Cronje 2013-2017 // // This software is licensed under the Apache License 2.0 // See http://www.apache.org/licenses/LICENSE-2.0 for license details