View
5
Download
0
Category
Preview:
Citation preview
at#bedcon
Gradle2.0andbeyondlatestefforts,currentstatus&roadmap
at#bedcon
RenéGröschkePrincipalEngineer@GradleInc.
@breskeby
breskeby
rene@gradle.com
at#bedcon
Gradleinanutshellcompletelyopensource
apache2licensed
drivenbyGradleInc.
at#bedcon
Gradleinanutshell
at#bedcon
Gradleinanutshell
at#bedcon
Gradleinanutshell
at#bedcon
GradleinanutshellAsimplejavaproject
apply plugin:"java"
version = file("version.txt").text
repositories { jcenter()}
dependencies { testCompile "junit:junit:4.+"}
task printVersion << { println "We're using - version '$version'!" }
at#bedcon
Gradle2.0Released1stJuly2014
at#bedcon
Gradle2.7Released14thSeptember2015
at#bedcon
Let’stakeacloserlookonPluginPortal
PlaySupport
GradleTestKit
EvenbetterDependencyManagement
NativeBuildSupportimprovements
EnhancedToolingAPI
at#bedcon
PluginPortal
at#bedcon
PluginPortalII
at#bedcon
PlaySupportDEMO
at#bedcon
ContinousMode> gralde build -t
at#bedcon
GradleTestKitFunctionaltestingofyourbuildlogic
def setup() { buildFile = testProjectDir.newFile('build.gradle')}
def "hello world task prints hello world"() { given: buildFile << """ task helloWorld { doLast { println 'Hello world!' } } """
when: def result = GradleRunner.create() .withProjectDir(testProjectDir.root) .withArguments('helloWorld') .build()
then: result.standardOutput.contains('Hello world!') result.task(":helloWorld").outcome == SUCCESS}
at#bedcon
DependencyManagement
at#bedcon
DependencyResolveRulesForcingconsistentversionforagroupoflibraries
configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> if (details.requested.group == 'org.gradle') { details.useVersion '2.7' } }}
at#bedcon
DependencyResolveRulesUsingacustomversioningscheme
configurations.all { resolutionStrategy { eachDependency { DependencyResolveDetails d -> if (d.requested.version == 'default') { def version = findDefaultVersion(d.requested.group, d.requested.name) d.useVersion version } } }}
Object findDefaultVersion(String group, String name) { // some custom logic that resolves the default // version into a specific version "1.0"}
at#bedcon
DependencyResolveRulesChangingdependencygroupand/ornameattheresolution
configurations.all { resolutionStrategy { eachDependency { DependencyResolveDetails details -> if (details.requested.name == 'groovy-all') { //prefer 'groovy' over 'groovy-all': details.useTarget(group: details.requested.group, name: 'groovy', version: details.requested.version) } if (details.requested.name == 'log4j') { //prefer 'log4j-over-slf4j' over 'log4j', details.useTarget "org.slf4j:log4j-over-slf4j:1.7.10" } } }}
at#bedcon
ComponentSelectionRulesdependencies { compile 'org.slf4j:slf4j-api:+' testCompile 'junit:junit:4.11'}
configurations { all { resolutionStrategy { componentSelection { withModule("org.slf4j:slf4j-api") { selection -> if(selection.candidate.version == "1.7.10") { selection.reject("known buggy version") } } } } }}
at#bedcon
ArtifactQueryApitask resolveMavenPomFiles << { def componentIds = configurations.compile.incoming.resolutionResult.allDependencies.collect { it.selected.id }
def result = dependencies.createArtifactResolutionQuery() .forComponents(componentIds) .withArtifacts(MavenModule, MavenPomArtifact) .execute()
for(component in result.resolvedComponents) { component.getArtifacts(MavenPomArtifact).each { def pom = new XmlSlurper().parse(it.file) println pom.url } }}
at#bedcon
DependencySubstitutionAllowselasticdependencies
configurations.all { resolutionStrategy.dependencySubstitution { substitute project(":api") with module("org.utils:api:1.3") }}
at#bedcon
BuildshipEclipseplugindevelopedfromscratchbyGradleInc.
Partoftheeclipsefoundation
Wejustleftincubatorstatuslastweek
Shippedaspartofthemars.1release(25.09.2015)
at#bedcon
BuildshipDemo
at#bedcon
CurrentfocusNewGradlemodel
Dependencymanagement
Betterdomainmodelling
at#bedcon
Dependencymanagement
at#bedcon
Dependencymanagementtodealwithdependencieswehave:
group,name,version
classifier,customivyconfigurations
at#bedcon
Dependencymanagementtodealwithdependencieswehave:
group,name,version
classifier,customivyconfigurations
butweneedtodealwith:
java,groovy,scalaversions
android,nativetargetplatforms,allkindofjavascript
at#bedcon
Dependencymanagement
at#bedcon
DependencymanagementAllowvariantawaredependencymanagement
at#bedcon
DependencymanagementAllowvariantawaredependencymanagement
Supportarbitrarydimensions+custommetadata
at#bedcon
BetterdomainmodellingDomainmodellingisGradle’sstrength.
Wewantittobeevenbetter.
at#bedcon
BetterdomainmodellingDomainmodellingisGradle’sstrength.
Wewantittobeevenbetter.
Strongermodeling↪TheJARisnotthetaskthatcreatesit.
Cleanermodeling↪Avoidmixingexecutionconcernsintothedatamodel.
Collaborativemodeling↪IknowhowtodosomethingtoJARs.
Comprehensiblemodels↪WhoiscontributingtothecontentsofthisJAR?
at#bedcon
AnewGradlemodel
at#bedcon
Thecurrentmodelconfiguration➞execution
at#bedcon
Thecurrentmodelconfiguration➞execution
configuration:
input=buildlogic
output=buildmodel
at#bedcon
Thecurrentmodelconfiguration➞execution
configuration:
input=buildlogic
output=buildmodel
execution:
input=buildmodel
output=buildartifacts
at#bedcon
Limitationsofthecurrentmodel
implementationofdeclarativebuildapiishard
doneintheimperativeway
eagerness
lazyness
hooks
scaling
at#bedcon
ToohardForbuildengineersandbuildusers.
Wecandobetter.
at#bedcon
ThenewGradlemodelAnewapproachtotheconfigurationphase.
Really,thesamesolutionforthe"executionphase"appliedtoconfiguration.
Agraphofdependentfunctions
Aninterpretabledatamodel
at#bedcon
ThenewGradlemodelIEnterRuleSource
class PersonRules extends RuleSource { @Model void person(Person p) {}
@Mutate void setFirstName(Person p) { p.firstName = "John" }
@Mutate void createHelloTask(ModelMap<Task> tasks, Person p) { tasks.create("hello") { doLast { println "Hello $p.firstName $p.lastName!" } } }}
at#bedcon
ThenewGradlemodelIIthebuildscript
apply plugin: PersonRules
model { person { lastName = "Smith" }}
at#bedcon
ThenewGradlemodelIIIAndroidexperimentalplugin
model { android { compileSdkVersion = 22 buildToolsVersion = "22.0.1"
defaultConfig.with { applicationId = "com.example.user.myapplication" minSdkVersion.apiLevel = 15 targetSdkVersion.apiLevel = 22 versionCode = 1 versionName = "1.0" } }}
at#bedcon
ThenewGradlemodelIVasanenablerfor
buildmuchfasterandmorememoryefficient
justconfigurewhatisrequired
allowfundamentalparallization
providebetterdiagnostics
reusecachedconfiguration
…
at#bedcon
Gradle3.0
at#bedcon
otherfutureplansjigsawsupport
shareddistributedcache
nextlevelnativebuildsupport
moredaemonutilisation
continuedtoolingimprovements
at#bedcon
Linksandpointershttps://docs.gradle.org/current/userguide/new_model.html
http://gradle.org/roadmap
http://discuss.gradle.org/c/roadmap
at#bedcon
Q&A
at#bedcon
thanks!
at#bedcon
TODOpdfexport→decktape.js
header/footer
makeasciidoctorofflineavailable
Recommended