Skip to content

Commit

Permalink
build.gradle configuration updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bgalek committed Feb 13, 2021
1 parent 96c53c0 commit 117ba7d
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 61 deletions.
52 changes: 3 additions & 49 deletions build.gradle
Expand Up @@ -8,6 +8,8 @@ plugins {
id 'com.gradle.plugin-publish' version '0.12.0'
id 'com.bmuschko.nexus' version '2.3.1' apply false
id 'io.codearte.nexus-staging' version '0.11.0' apply false
id 'com.coditory.integration-test' version "1.0.5"
id 'com.adarshr.test-logger' version '2.1.1'

id 'com.bmuschko.docker-remote-api' version '3.2.1'
}
Expand Down Expand Up @@ -51,20 +53,6 @@ sourceSets {
groovy { srcDirs = ["src/main/java", "src/main/groovy"] } // compile everything in src/ with groovy
}

integration {
java.srcDir project.file('src/integration/java')
groovy.srcDir project.file('src/integration/groovy')

resources.srcDir project.file('src/integration/resources')
resources.srcDir project.sourceSets.test.resources
resources.srcDir project.sourceSets.main.resources

compileClasspath = project.sourceSets.main.output +
project.sourceSets.test.output +
project.configurations.testRuntime
runtimeClasspath = output + compileClasspath
}

remoteTest {
java.srcDir project.file('src/test-remote/java')
groovy.srcDir project.file('src/test-remote/groovy')
Expand Down Expand Up @@ -112,24 +100,10 @@ dependencies {
testCompile group: 'org.apache.sshd', name: 'sshd-core', version: '1.6.0'
testCompile group: 'org.apache.sshd', name: 'sshd-git', version: '1.6.0'

testCompile gradleTestKit()
}

test {
testLogging {
events 'passed', 'skipped', 'failed'
exceptionFormat = 'full'
}
testImplementation gradleTestKit()
}

project.configurations {
integration {
extendsFrom project.configurations.testRuntime
description = 'Dependencies for integration tests'
transitive = true
visible = true
}

remoteTest {
extendsFrom project.configurations.testRuntime
description = 'Dependencies for tests with Docker'
Expand All @@ -138,21 +112,6 @@ project.configurations {
}
}

task integrationTest(type: Test) {
testClassesDirs = project.sourceSets.integration.output.classesDirs
classpath = project.sourceSets.main.output +
project.sourceSets.test.output +
project.sourceSets.integration.runtimeClasspath +
project.configurations.testRuntime +
project.configurations.integrationRuntime

testLogging {
events 'passed', 'skipped', 'failed'
showStandardStreams = true
exceptionFormat = 'full'
}
}

task buildDockerImage(type: com.bmuschko.gradle.docker.tasks.image.DockerBuildImage) {
inputDir = file('docker')
tag = 'test/axion-release-remote:latest'
Expand Down Expand Up @@ -182,11 +141,6 @@ task remoteTest(type: Test) {
project.configurations.testRuntime +
project.configurations.remoteTestRuntime

testLogging {
events 'passed', 'skipped', 'failed'
exceptionFormat = 'full'
}

dependsOn startDockerContainer
finalizedBy stopDockerContainer
}
Expand Down
@@ -1,6 +1,7 @@
package pl.allegro.tech.build.axion.release

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.Releaser
Expand All @@ -10,6 +11,7 @@ import pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext

class CreateReleaseTask extends DefaultTask {

@Input
@Optional
VersionConfig versionConfig

Expand Down
@@ -1,6 +1,7 @@
package pl.allegro.tech.build.axion.release

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.NextVersionMarker
Expand All @@ -11,6 +12,7 @@ import pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext

class MarkNextVersionTask extends DefaultTask {

@Input
@Optional
VersionConfig versionConfig

Expand Down
@@ -1,6 +1,7 @@
package pl.allegro.tech.build.axion.release

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.VersionConfig
Expand All @@ -9,6 +10,7 @@ import pl.allegro.tech.build.axion.release.infrastructure.output.OutputWriter

class OutputCurrentVersionTask extends DefaultTask {

@Nested
@Optional
VersionConfig versionConfig

Expand Down
@@ -1,6 +1,7 @@
package pl.allegro.tech.build.axion.release

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.Releaser
Expand All @@ -11,6 +12,7 @@ import pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext

class PushReleaseTask extends DefaultTask {

@Input
@Optional
VersionConfig versionConfig

Expand Down
@@ -1,6 +1,7 @@
package pl.allegro.tech.build.axion.release

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.Releaser
Expand All @@ -11,6 +12,7 @@ import pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext

class ReleaseTask extends DefaultTask {

@Input
@Optional
VersionConfig versionConfig

Expand Down
@@ -1,6 +1,7 @@
package pl.allegro.tech.build.axion.release

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.LocalOnlyResolver
Expand All @@ -14,6 +15,7 @@ import pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext

class VerifyReleaseTask extends DefaultTask {

@Input
@Optional
VersionConfig versionConfig

Expand Down
@@ -1,11 +1,16 @@
package pl.allegro.tech.build.axion.release.domain

import org.gradle.api.tasks.Input

class ChecksConfig {

@Input
boolean aheadOfRemote = true

@Input
boolean uncommittedChanges = true

@Input
boolean snapshotDependencies = true

}
@@ -1,13 +1,20 @@
package pl.allegro.tech.build.axion.release.domain

import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Nested

class NextVersionConfig {


@Input
String suffix = 'alpha'

@Input
String separator = '-'


@Nested
Closure<String> serializer = NextVersionSerializer.DEFAULT.serializer


@Nested
Closure<String> deserializer = NextVersionSerializer.DEFAULT.deserializer

void serializer(String type) {
Expand Down
@@ -1,20 +1,35 @@
package pl.allegro.tech.build.axion.release.domain

import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Optional

class RepositoryConfig {

@Input
String type = 'git'

@InputDirectory
File directory

@Input
String remote = 'origin'

@Input
@Optional
def customKey

@Input
@Optional
String customKeyPassword


@Input
@Optional
String customUsername


@Input
String customPassword = ''

@Input
boolean pushTagsOnly = false
}
@@ -1,5 +1,7 @@
package pl.allegro.tech.build.axion.release.domain

import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Nested
import pl.allegro.tech.build.axion.release.domain.properties.TagProperties
import pl.allegro.tech.build.axion.release.domain.scm.ScmPosition

Expand All @@ -9,16 +11,22 @@ class TagNameSerializationConfig {

static final String DEFAULT_PREFIX = 'release'

@Input
String prefix = DEFAULT_PREFIX

@Input
Map<String, String> branchPrefix = [:]

@Input
String versionSeparator = DEFAULT_VERSION_SEPARATOR

@Nested
Closure serialize = TagNameSerializer.DEFAULT.serializer

@Nested
Closure deserialize = TagNameSerializer.DEFAULT.deserializer

@Nested
Closure initialVersion = defaultInitialVersion()

private static Closure defaultInitialVersion() {
Expand Down
@@ -1,6 +1,8 @@
package pl.allegro.tech.build.axion.release.domain

import org.gradle.api.Project
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Nested
import pl.allegro.tech.build.axion.release.ReleasePlugin
import pl.allegro.tech.build.axion.release.domain.hooks.HooksConfig
import pl.allegro.tech.build.axion.release.domain.properties.Properties
Expand All @@ -15,40 +17,58 @@ class VersionConfig {

private final Project project

@Input
boolean localOnly = false

@Input
boolean dryRun

@Input
boolean ignoreUncommittedChanges = true

@Input
boolean useHighestVersion = false

@Nested
RepositoryConfig repository

@Nested
TagNameSerializationConfig tag = new TagNameSerializationConfig()

@Nested
Closure versionCreator = PredefinedVersionCreator.SIMPLE.versionCreator

@Input
Map<String, Object> branchVersionCreator = [:]

@Nested
Closure versionIncrementer = PredefinedVersionIncrementer.versionIncrementerFor('incrementPatch')

@Input
Map<String, Object> branchVersionIncrementer = [:]

@Input
Pattern releaseBranchPattern = Pattern.compile('^release(/.*)?$')

@Nested
ChecksConfig checks = new ChecksConfig()

@Input
boolean sanitizeVersion = true

@Input
boolean createReleaseCommit = false

@Nested
Closure releaseCommitMessage = PredefinedReleaseCommitMessageCreator.DEFAULT.commitMessageCreator

@Nested
NextVersionConfig nextVersion = new NextVersionConfig()

@Nested
HooksConfig hooks = new HooksConfig()

@Nested
MonorepoConfig monorepoConfig = new MonorepoConfig()

private Context context
Expand Down Expand Up @@ -126,16 +146,19 @@ class VersionConfig {
this.branchVersionIncrementer = creators
}

@Input
String getVersion() {
ensureVersionExists()
return resolvedVersion.decoratedVersion
}

@Input
String getUndecoratedVersion() {
ensureVersionExists()
return resolvedVersion.undecoratedVersion
}

@Nested
VersionScmPosition getScmPosition() {
ensureVersionExists()
return new VersionScmPosition(
Expand All @@ -151,12 +174,14 @@ class VersionConfig {
}
}

@Nested
VersionService.DecoratedVersion getUncachedVersion() {
ensureContextExists()
Properties rules = context.rules()
return context.versionService().currentDecoratedVersion(rules.version, rules.tag, rules.nextVersion)
}

@Nested
VersionService getVersionService() {
ensureContextExists()
return context.versionService()
Expand Down

0 comments on commit 117ba7d

Please sign in to comment.