Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
FIXED #9 - Restored issue with pattern based resolvers caused by inte…
Browse files Browse the repository at this point in the history
…rnal API change in Gradle 2.3
  • Loading branch information
ysb33r committed Oct 24, 2015
1 parent e32b052 commit 9c57450
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* https://github.com/ysb33r/ivypot-gradle-plugin/issues/2[Issue #2] - Add support for `repositories.flatDir`.

== 0.3.5

* https://github.com/ysb33r/ivypot-gradle-plugin/issues/8[Issue #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.
Expand Down
19 changes: 17 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,24 @@ apply plugin : 'org.ysb33r.gradletest'

apply from: 'gradle/integration-tests.gradle'

version = '0.3.5'
group = 'org.ysb33r.gradle'
sourceCompatibility = 1.6
targetCompatibility = 1.6

version = '0.3.5-SNAPSHOT'
group = 'org.ysb33r.gradle'

plugins.withType(JavaPlugin) {

project.tasks.withType(JavaCompile) { task ->
task.sourceCompatibility = project.sourceCompatibility
task.targetCompatibility = project.targetCompatibility
}

project.tasks.withType(GroovyCompile) { task ->
task.sourceCompatibility = project.sourceCompatibility
task.targetCompatibility = project.targetCompatibility
}
}

repositories {
jcenter()
Expand Down Expand Up @@ -113,7 +126,9 @@ gradleTest {
versions '2.2'
versions '2.3'
versions '2.4'
versions '2.7'
versions '2.8'

inputs.files jar
inputs.dir file('gradleTest')
}
22 changes: 21 additions & 1 deletion src/gradleTest/basicTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ apply plugin : 'org.ysb33r.ivypot'

configurations {
simple
github
}

dependencies {
// Copying this plugin as it has a nice svnkit dependency set
simple 'at.bxm.gradleplugins:gradle-svntools-plugin:1.1'
github ':ivypot-gradle-plugin:master@zip'
}

syncRemoteRepositories {
Expand Down Expand Up @@ -42,6 +44,24 @@ task syncRemoteRepositories2 ( type : org.ysb33r.gradle.ivypot.OfflineRepository
configurations 'simple'
}

task syncRemoteRepositories3 ( type : org.ysb33r.gradle.ivypot.OfflineRepositorySync) {
repoRoot "${buildDir}/repo3"

repositories {
jcenter()

ivy {
url 'https://github.com/ysb33r/'
layout 'pattern', {
ivy 'none'
artifact '[module]/archive/[revision].[ext]'
}
}
}

configurations 'simple'
}

task runGradleTest {
dependsOn syncRemoteRepositories, syncRemoteRepositories2
dependsOn syncRemoteRepositories, syncRemoteRepositories2, syncRemoteRepositories3
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class OfflineRepositorySync extends DefaultTask {
private static RepositoryHandler createRepositoryHandler(Gradle gradle) {
Instantiator instantiator

// This handles this difference in the internal API between 2.3 & 2.4
// This handles a difference in the internal API between 2.3 & 2.4
if (DirectInstantiator.metaClass.static.hasProperty('INSTANCE')) {
instantiator - DirectInstantiator.INSTANCE
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@

package org.ysb33r.gradle.ivypot.internal

import groovy.transform.TypeChecked
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
import org.gradle.api.artifacts.repositories.IvyArtifactRepositoryMetaDataProvider
import org.gradle.api.artifacts.repositories.PasswordCredentials
import org.gradle.api.internal.artifacts.repositories.layout.GradleRepositoryLayout
import org.gradle.api.internal.artifacts.repositories.layout.IvyRepositoryLayout
import org.gradle.api.internal.artifacts.repositories.layout.MavenRepositoryLayout
import org.gradle.api.internal.artifacts.repositories.layout.PatternRepositoryLayout
import org.gradle.api.internal.artifacts.repositories.resolver.ResourcePattern
import org.ysb33r.gradle.ivypot.IvyXml
import org.ysb33r.gradle.ivypot.OfflineRepositorySync

/**
* @author Schalk W. Cronjé
Expand Down Expand Up @@ -72,23 +66,34 @@ class IvyRepository implements IvyArtifactRepository, IvyXml, RepositoryTraits {
* @param layoutName The name of the layout to use.
*/
@Override
void layout(String layoutName) {
@TypeChecked
void layout(final String layoutName) {
final String namespace = 'org.gradle.api.internal.artifacts.repositories.layout.'
String repositoryLayoutName
Class layoutClass
switch (layoutName) {
case 'maven':
repositoryLayout = new MavenRepositoryLayout()
break
case 'ivy':
repositoryLayout = new IvyRepositoryLayout()
break
case 'gradle':
repositoryLayout = new GradleRepositoryLayout()
break
case 'pattern':
repositoryLayout = new PatternRepositoryLayout()
repositoryLayoutName = layoutName.capitalize()
break
default:
throw new UnsupportedOperationException("'${layoutName}' is not a valid layout")
}

try {
layoutClass = Class.forName "${namespace}${repositoryLayoutName}RepositoryLayout"
} catch(ClassNotFoundException e) {
// Change in class name prefix in Gradle 2.3 from 'Pattern' to 'DefaultIvyPattern'.
if(layoutName == 'pattern') {
layoutClass = Class.forName "${namespace}DefaultIvy${repositoryLayoutName}RepositoryLayout"
} else {
throw e
}
}

repositoryLayout = layoutClass.newInstance()
}

/**
Expand Down

0 comments on commit 9c57450

Please sign in to comment.