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 #42 from ysb33r/issue-29
Browse files Browse the repository at this point in the history
Issues 29, 34, 40, 41
  • Loading branch information
ysb33r authored May 8, 2019
2 parents fe6a76a + 30ddd3e commit da364cc
Show file tree
Hide file tree
Showing 50 changed files with 1,956 additions and 482 deletions.
26 changes: 24 additions & 2 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
= CHANGELOG
:issue: link:https://github.com/ysb33r/ivypot-gradle-plugin/issues/
:contributor: link:https://github.com/

== 0.10 - Roadmap

=== Improvements

* {issue}29[#29] Added realm parameter for credentials (Thank you Jakob Hendeß).
* {issue}34[#34] Resolve classifiers and extensions correctly.
* {issue}40[#40] Run repository synchronisation process in separate JVM.
* {issue}41[#41] Allow arbitrary binaries to be cached.

=== Breaking changes

* Not binary compatible with 0.9.

=== Contributors

* {contributor}jhendess[Jakob Hendeß]

== 0.9

=== Compatibility

* Gradle compatibility tested 4.0 - 5.2.1
* Gradle compatibility tested 5.0 - 5.2.1

=== Breaking changes

* Minimum JDK8 required
* Major rewrite of the internal reposiotry support. Relies less on Gradle less APIs and provides a DSL layer that mimics the Gradle `repository` structure, but is not binary compatible.
* Major rewrite of the internal repository support. Relies less on Gradle less APIs and provides a DSL layer that mimics the Gradle `repository` structure, but is not binary compatible.

=== Compatibility

* Gradle compatibility tested 4.0 - 5.2.1

== 0.8

Expand Down
55 changes: 54 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ security processes to be applied to the binary files before committing them to a

== Previous versions

* https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_9_0[Release 0.9]
* https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_8_0[Release 0.8]
* https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_7_0[Release 0.7]
* https://github.com/ysb33r/ivypot-gradle-plugin/tree/RELEASE_0_6_0[Release 0.6]
Expand Down Expand Up @@ -191,6 +192,57 @@ Now you just have to run `./gradlew syncRemoteRepositories` or `./gradlew :sync:

NOTE: Also see `src/gradleTest/multiProject` as an example of how this works. (That's actually the compability test we use for multi-projects).

== Caching arbitrary binaries

As from 0.10 it is now possible to cache arbitrary binary files with a path that typically matches that on the server. This is especially useful for people that need to perform tests where binaries are downloaded many times.

=== Configuring binary repositories

[source,groovy]
----
syncRemoteRepositories {
binaryRepositories {
nodejs { // <1>
rootUri = 'https://nodejs.org/dist/' // <2>
artifactPattern = 'v[revision]/[module]-v[revision]-[classifier].[ext]' // <3>
}
}
}
----
<1> The name of the repository. This will also be treated as the group/organisation names.
<2> The root URI of the remote repository. Only `file` and `http(s)` schemes are supported.
<3> A pattern similar to that if Ivy for resolving the artifact path below the root URI.
This is also used to calculate a relative path for storing the binary locally.
Note that `classifier` is supported.

=== Specifying binaries locally

If you have one project then the easiest is to specify the binaries within the
`syncRemoteRepositories` task using the `cachedBinaries.add` DSL keyword.

[source,groovy]
----
syncRemoteRepositories {
cacheBinaries.add 'nodejs:node:7.10.0:[email protected]'
}
----

=== Specifying binaries in other projects

It might be useful to rather specify binaries to be cached within the subproject where they are required and then let the syncRemoteRepositories task discover them. In order to achieve this apply a plugin which adds an extension to the `dependencies` block.

[source,groovy,subs="+attributes"]
----
plugins {
id 'org.ysb33r.binarypot.base' version '{revnumber}' // <1>
}
dependencies {
cachedBinaries.add 'nodejs:node:7.10.0:[email protected]' //<2>
}
----
<1> Adds the `cachedBinaries` extenion to `dependencies` block.
<2> The same syntax is used, but the organisation/group name must match that of a binary repository as defined in `syncRemoteRepositories.

== Adding buildscript dependencies

Expand Down Expand Up @@ -219,9 +271,10 @@ which relies on finding a compiler jar in a certain named way failed when used w
== Flat directories

The `flatDir` repository supported by Gradle is not supported as it does not make sense. The purpose of this plugin is
to cache remote repositories into a useable local repository. If a user already has a `flatDir` it does not need be be
to cache remote repositories into a usable local repository. If a user already has a `flatDir` it does not need be be
cached and if need be it can simply be copied.


== Limitations

* The resolution process cannot be fine-tuned at present - not to the level at least which is described
Expand Down
79 changes: 54 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ plugins {
id 'com.gradle.build-scan' version '2.2.1'
id 'groovy'
id 'maven'
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '0.9.9'
id 'com.github.hierynomus.license' version '0.12.1'
id 'org.ysb33r.gradletest' version '2.0-beta.3'
id 'org.ysb33r.gradletest' version '2.0-rc.4'
id 'org.ysb33r.os' version '0.9'
}

Expand All @@ -38,58 +39,77 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

ext {
ivyVersion = '2.4.0'
groovyLongVer = GroovySystem.version
groovyShortVer = GroovySystem.version.replaceAll(/\.\d+$/, '')

ivyJar = fileTree("${gradle.gradleHomeDir}/lib/plugins") {
include 'ivy*.jar'
}
}

task foo {
doLast {
println ivyJar.files
}
}
apply from: 'gradle/ivyAntVersions.gradle'

repositories {
jcenter()
}

configurations {
spock
ivy

testCompile.extendsFrom spock
integrationTestCompile.extendsFrom spock
remoteTestCompile.extendsFrom spock
}

dependencies {
compile 'org.ysb33r.gradle:grolifant:0.10'
spock "org.spockframework:spock-core:1.2-groovy-${groovyShortVer}", {
exclude module: 'groovy-all'
exclude group: 'org.codehaus.groovy'
}

compileOnly "org.apache.ivy:ivy:${ivyVersion}"
compile 'org.ysb33r.gradle:grolifant:0.12.1'
compile gradleApi()
compile localGroovy()

testCompile "org.spockframework:spock-core:1.2-groovy-${groovyShortVer}", {
exclude module: 'groovy-all'
}
testCompile 'org.slf4j:slf4j-api:1.7.13'
testCompile 'org.slf4j:slf4j-simple:1.7.13'

testRuntime ivyJar
}
integrationTestCompile gradleTestKit()

test {
systemProperties DONT_LOOK_FOR_IVY_JAR: 1
remoteTestCompile localGroovy()
remoteTestRuntime "org.codehaus.groovy:groovy-ant:${groovyLongVer}"
remoteTestRuntime "org.apache.ivy:ivy:${ivyVersion}"
}

integrationTest {
systemProperties TESTROOT: buildDir

tasks.withType(Test) {
if (gradle.startParameter.isOffline()) {
systemProperties OFFLINE: 1
}
}


processResources {
from generateIvyAntVersions, {
into 'META-INF'
}
}

license {
header = rootProject.file('config/HEADER')
strictCheck = true
ignoreFailures = false
mapping {
groovy = 'DOUBLESLASH_STYLE'
}
ext.year = '2013-2018'
excludes(['**/*.ad', '**/*.asciidoc', '**/*.adoc', '**/*.md', '**/*.properties', '**/*CompatibilitySpec.groovy'])
ext.year = '2013-2019'
excludes([
'**/*.ad',
'**/*.asciidoc',
'**/*.adoc',
'**/*.md',
'**/*.properties',
'**/*.dsl.groovySpec.groovy',
'**/*.dsl.kotlinSpec.groovy',
])
}

pluginBundle {
Expand All @@ -104,13 +124,16 @@ pluginBundle {
id = 'org.ysb33r.ivypot'
displayName = 'Plugin for maintaining an offline respository'
}
binaryPotBasePlugin {
id = 'org.ysb33r.ivypot.binary.base'
displayName = 'Plugin that allows specification of arbitrary binaries to be cached by the ivypot plugin'
}
}

mavenCoordinates {
groupId = project.group
artifactId = 'ivypot'
}

}

publishPlugins {
Expand All @@ -120,7 +143,7 @@ publishPlugins {
}

gradleTest {
versions '5.2.1'
versions '5.4.1'
versions '5.0'

inputs.files jar
Expand All @@ -132,10 +155,16 @@ gradleTest {
if (OS.windows) {
gradleArguments '-g', file("${buildDir}/gradleTest/userHome").absolutePath.replaceAll(~$/\\/$, '/')
}

mustRunAfter test, integrationTest, remoteTest
}

task release {
group 'release'
description 'Life-cycle task for releasing the plugin'
dependsOn build, publishPlugins
}

pluginManager.withPlugin('idea') {
tasks.ideaModule.dependsOn processResources
}
34 changes: 18 additions & 16 deletions gradle/integration-tests.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// This is based upon what Rob Fletcher has done at
// https://raw.githubusercontent.com/robfletcher/gradle-compass/master/gradle/integration-tests.gradle
import org.gradle.util.GradleVersion


sourceSets {
integrationTest {
}

remoteTest {
compileClasspath = sourceSets.main.output + configurations.remoteTestCompile
runtimeClasspath = output + compileClasspath + configurations.remoteTestRuntime
}
}

configurations {
integrationTestCompile {
Expand All @@ -11,26 +21,18 @@ configurations {
}
}

sourceSets {
integrationTest {
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 remoteTest(type: Test, dependsOn: jar) {
testClassesDirs = sourceSets.remoteTest.output.classesDirs
classpath = sourceSets.remoteTest.runtimeClasspath
mustRunAfter test
}

task integrationTest(type: Test, dependsOn: jar) {
if(GradleVersion.current() < GradleVersion.version('4.0')) {
testClassesDir = sourceSets.integrationTest.output.classesDir
} else {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
}
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
mustRunAfter test
mustRunAfter test, remoteTest
}

check.dependsOn integrationTest
check.dependsOn integrationTest, remoteTest


21 changes: 21 additions & 0 deletions gradle/ivyAntVersions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
task generateIvyAntVersions {
ext {
outFile = file("${buildDir}/ivyAnt/org.ysb33r.gradle.ivypot.versions.properties")
ivyVersion = { project.ext.ivyVersion }
groovyVersion = { project.ext.groovyLongVer }
}

inputs.properties.put('versions', "${ivyVersion()}${groovyVersion()}" )
outputs.file(outFile)

doLast {
def props = new Properties()
props.putAll([
'ivy.version': ivyVersion.call(),
'groovy.version': groovyVersion.call()
])
outFile.withOutputStream { strm ->
props.store(strm,'')
}
}
}
13 changes: 13 additions & 0 deletions src/gradleTest/basicTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ configurations {
github
}

repositories {
jcenter()
}

dependencies {
// Copying this plugin as it has a nice svnkit dependency set
simple 'at.bxm.gradleplugins:gradle-svntools-plugin:1.1'
Expand All @@ -22,6 +26,15 @@ syncRemoteRepositories {
}
}

binaryRepositories {
nodejs {
rootUri = 'https://nodejs.org/dist/'
artifactPattern = 'v[revision]/[module]-v[revision]-[classifier].[ext]'
}
}

cachedBinaries.add 'nodejs:node:7.10.0:[email protected]'

configurations 'simple'
}

Expand Down
5 changes: 4 additions & 1 deletion src/gradleTest/multiProject/proj1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apply plugin : 'java'
plugins {
id 'java'
id 'org.ysb33r.ivypot.binary.base'
}

dependencies {
compile 'org.tukaani:xz:1.6'
Expand Down
Loading

0 comments on commit da364cc

Please sign in to comment.