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

Commit

Permalink
Merge pull request #48 from ysb33r/development
Browse files Browse the repository at this point in the history
Release 0.11
  • Loading branch information
ysb33r authored Feb 13, 2020
2 parents 2d48a6b + c78531e commit 80a6a55
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ script:
- ./gradlew -S clean build --console=plain --info --scan

jdk:
- oraclejdk8
- openjdk8

os:
- linux
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
:issue: link:https://github.com/ysb33r/ivypot-gradle-plugin/issues/
:contributor: link:https://github.com/

== 0.11

=== Improvements

* {issue}44[#44] Compatible with Gradle 6.1.
* {issue}47[#47] Honour order of repositories as listed.

=== Compatibility

* Gradle compatibility tested 5.0 - 6.1

== 0.10

=== Improvements
Expand Down
15 changes: 9 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,19 @@ apply plugin : 'org.ysb33r.ivypot'
syncRemoteRepositories {
addAllProjects() // <1>
repoDir offlineRepoDir <1>
addProject ':a:b' // <2>
addAllProjects() // <2>
addProject ':a:b','compile','testCompile' // <3>
addProject ':a:b' // <3>
addProject ':a:b','compile','testCompile' // <4>
}
----
<1> Adds all configurations from all subprojects and the rootproject with the exception of the current project. `buildscript` dependencies are not added via this call.
<2> Adds all configurations from project `:a:b` as long as the current project is not called `:a:b`.
<3> Adds only the `compile` and `testCompile` configurations from project `:a:b`. Once again `:a:b` must not be the current project.
<1> Set offline repository root to a variable that is visible to all projects.
<2> Adds all configurations from all subprojects and the rootproject with the exception of the current project. `buildscript` dependencies are not added via this call.
<3> Adds all configurations from project `:a:b` as long as the current project is not called `:a:b`.
<4> Adds only the `compile` and `testCompile` configurations from project `:a:b`. Once again `:a:b` must not be the current project.

Now you just have to run `./gradlew syncRemoteRepositories` or `./gradlew :sync:syncRemoteRepositories` from the top.

Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ buildScan {

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

version = '0.10'
version = '0.11-SNAPSHOT'
group = 'org.ysb33r.gradle'
sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down Expand Up @@ -143,6 +143,7 @@ publishPlugins {
}

gradleTest {
versions '6.1'
versions '5.4.1'
versions '5.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,44 @@ class OfflineRepositorySyncIntegrationSpec extends Specification {
}
}

@Issue([
'https://github.com/ysb33r/ivypot-gradle-plugin/issues/47',
'https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/528'
])
void 'Order of repositories should be honoured for resolving artifacts'() {

setup:
File ivySettingsXml = new File(projectDir, 'build/tmp/syncRemoteRepositories/ivysettings.xml')
writeBuildFile """
configurations {
compile
}
// tag::example_two_repos[]
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
}
syncRemoteRepositories {
repositories {
mavenCentral()
jcenter()
}
}
// end::example_two_repos[]
"""

when:
BuildResult result = build()
def ivySettings = new XmlSlurper().parse(ivySettingsXml)

then:
file_exists 'org.codehaus.groovy/groovy-all/2.3.11/ivy-2.3.11.xml'

ivySettings.resolvers.chain.ibiblio[0].@name == 'MavenRepo'
ivySettings.resolvers.chain.ibiblio[1].@name == 'BintrayJCenter'
}

void 'Honour non-transitive dependencies'() {

setup:
Expand Down Expand Up @@ -247,7 +285,7 @@ class OfflineRepositorySyncIntegrationSpec extends Specification {
syncRemoteRepositories {
repositories {
maven { url 'http://rubygems.lasagna.io/proxy/maven/releases' }
maven { url 'https://mavengems.jruby.org' }
}
}
// end::example_rubygems[]
Expand Down Expand Up @@ -350,11 +388,11 @@ class OfflineRepositorySyncIntegrationSpec extends Specification {

private BuildResult build() {
GradleRunner.create().withDebug(true)
.withPluginClasspath()
.withProjectDir(projectDir)
.withArguments(['-i', '-s', DEFAULT_TASK])
.forwardOutput()
.build()
.withPluginClasspath()
.withProjectDir(projectDir)
.withArguments(['-i', '-s', DEFAULT_TASK])
.forwardOutput()
.build()
}

void withBuildScript(String content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,8 @@ class OfflineRepositorySync extends DefaultTask {

@CompileDynamic
OfflineRepositorySync() {

repositories = new RepositoryHandler(project)

inputs.properties.put('project configurations', { OfflineRepositorySync ors ->
Set<Configuration> configs = ors.getConfigurations()
configs.collect { Configuration c ->
c.dependencies.collect { Dependency d ->
"${d.group}:${d.name}:${d.version}"
}.join(',')
}.join('|')
}.curry(this))

inputs.properties.put('cached binaries', { OfflineRepositorySync ors ->
ors.binaries*.toString().join('')
}.curry(this))

binaryRepositories = project.container(BinaryRepository) { String repoName ->
DefaultBinaryRepository.create(repoName, null, null)
}
Expand All @@ -80,6 +66,24 @@ class OfflineRepositorySync extends DefaultTask {
}

extBinaries = extensions.create('cachedBinaries', DependencyHandlerExtension, project)

Closure projectConfigurations = { OfflineRepositorySync ors ->
Set<Configuration> configs = ors.getConfigurations()
configs.collect { Configuration c ->
c.dependencies.collect { Dependency d ->
"${d.group}:${d.name}:${d.version}"
}.join(',')
}.join('|')
}.curry(this)

Closure cachedBinaries = { OfflineRepositorySync ors ->
ors.binaries*.toString().join('')
}.curry(this)

inputs.properties([
'project configurations': projectConfigurations,
'cached binaries': cachedBinaries
])
}

/** The pattern that will be used to write artifacts into the target repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package org.ysb33r.gradle.ivypot.internal
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import groovy.xml.MarkupBuilder
import org.ysb33r.gradle.ivypot.repositories.Repository
import org.ysb33r.gradle.ivypot.repositories.RepositoryHandler
import org.ysb33r.grolifant.api.FileUtils

Expand All @@ -27,13 +28,17 @@ class IvyUtils {
@CompileDynamic
static void writeSettingsFile(
File settingsFile,
RepositoryHandler repositories,
RepositoryHandler repositoryHandler,
File repoRoot,
File cacheDir,
String ivyPattern,
String artifactPattern,
Iterable<Map<String, String>> repositoryCredentials
) {
List<Repository> repositories = repositoryHandler.sort { a,b ->
a.index <=> b.index
}

def xmlWriter = new StringWriter()
def xml = new MarkupBuilder(xmlWriter)
xml.ivysettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ import org.gradle.api.Named
import org.ysb33r.gradle.ivypot.IvyXml

/**
* @since 1.0
*
*/
@CompileStatic
interface Repository extends Named, IvyXml {
void setName(final String name)

/**
*
* @param idx
*
* @since 0.11
*/
void setIndex(int idx)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ class RepositoryHandler {
}

MavenArtifactRepository jcenter() {
(MavenArtifactRepository)addByName('BintrayJCenter', new JCenter())
(MavenArtifactRepository) addByName('BintrayJCenter', new JCenter())
}

MavenArtifactRepository mavenCentral() {
(MavenArtifactRepository)addByName('MavenRepo', new MavenCentral())
(MavenArtifactRepository) addByName('MavenRepo', new MavenCentral())
}

MavenArtifactRepository mavenLocal() {
(MavenArtifactRepository)addByName('MavenLocal', new MavenLocal())
(MavenArtifactRepository) addByName('MavenLocal', new MavenLocal())
}

MavenArtifactRepository google() {
(MavenArtifactRepository)addByName('Google', new Google())
(MavenArtifactRepository) addByName('Google', new Google())
}

MavenArtifactRepository maven(Closure configurator) {
MavenArtifactRepository repo = new MavenArtifactRepository()
Closure cfg = (Closure)configurator.clone()
Closure cfg = (Closure) configurator.clone()
cfg.resolveStrategy = Closure.DELEGATE_FIRST
cfg.delegate = repo
addByName(
Expand All @@ -67,12 +67,12 @@ class RepositoryHandler {
}

MavenArtifactRepository maven(Action<? super MavenArtifactRepository> configurator) {
addByName( "maven_${postfix}", new MavenArtifactRepository(), configurator)
addByName("maven_${postfix}", new MavenArtifactRepository(), configurator)
}

IvyArtifactRepository ivy(Closure configurator) {
IvyArtifactRepository repo = new IvyArtifactRepository()
Closure cfg = (Closure)configurator.clone()
Closure cfg = (Closure) configurator.clone()
cfg.resolveStrategy = Closure.DELEGATE_FIRST
cfg.delegate = repo
addByName(
Expand All @@ -83,24 +83,27 @@ class RepositoryHandler {
}

IvyArtifactRepository ivy(Action<? super IvyArtifactRepository> configurator) {
addByName( "ivy_${postfix}", new IvyArtifactRepository(), configurator)
addByName("ivy_${postfix}", new IvyArtifactRepository(), configurator)
}

private Repository addByName(final String name, Repository repo) {
repo.name = name
repo.index = registeredRepositories.size() + 1
registeredRepositories.add(repo)
repo
}

private MavenArtifactRepository addByName(final String name, MavenArtifactRepository repo, Action<? super MavenArtifactRepository> configurator) {
repo.name = name
repo.index = registeredRepositories.size() + 1
configurator.execute(repo)
registeredRepositories.add(repo)
repo
}

private IvyArtifactRepository addByName(final String name, IvyArtifactRepository repo, Action<? super IvyArtifactRepository> configurator) {
repo.name = name
repo.index = registeredRepositories.size() + 1
configurator.execute(repo)
registeredRepositories.add(repo)
repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.ysb33r.gradle.ivypot.repositories

import groovy.transform.CompileDynamic

import groovy.transform.CompileStatic
import org.gradle.api.Action
import org.gradle.api.GradleException
Expand Down Expand Up @@ -91,18 +91,12 @@ trait RepositoryTraits {
* Configure the Credentials for this repository using the supplied Closure.
*
* @code
* repositories {
* maven {
* credentials {
* username = 'joe'
* repositories {* maven {* credentials {* username = 'joe'
* password = 'secret'
* }
* }
* }
* @endcode
*}*}*}* @endcode
*/
void credentials(Closure closure) {
Closure cfg = (Closure)(closure.clone())
Closure cfg = (Closure) (closure.clone())
cfg.delegate = this.credentials
cfg()
}
Expand All @@ -126,7 +120,7 @@ trait RepositoryTraits {
*/
def <T extends org.gradle.api.credentials.Credentials> T getCredentials(Class<T> aClass) {
if (this.credentials instanceof T) {
return (T)(this.credentials)
return (T) (this.credentials)
} else {
throw new IllegalArgumentException("${Credentials.class.name} cannot be converted to ${aClass.name}")
}
Expand Down Expand Up @@ -170,6 +164,26 @@ trait RepositoryTraits {
this.name = name
}

/** Returns the proposed order number for this repository
*
* @return Order number
*
* @since 0.11
*/
int getIndex() {
this.order
}

/** Sets an order number for this repository
*
* @param idx Order number
*
* @since 0.11
*/
void setIndex(int idx) {
this.order = idx
}

void authentication(Action<? super AuthenticationContainer> 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")
}
Expand All @@ -178,7 +192,7 @@ trait RepositoryTraits {
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 int order
private String name
private Object url
private Credentials credentials = new Credentials()
Expand Down

0 comments on commit 80a6a55

Please sign in to comment.