Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import software.aws.toolkits.gradle.changelog.tasks.GenerateGithubChangeLog
plugins {
id("base")
id("toolkit-changelog")
id("toolkit-git-secrets")
id("toolkit-jacoco-report")
id("org.jetbrains.gradle.plugin.idea-ext")
}
Expand Down Expand Up @@ -42,7 +41,7 @@ dependencies {
aggregateCoverage(project(":ui-tests"))
}

tasks.register("runIde") {
tasks.register<DefaultTask>("runIde") {
doFirst {
throw GradleException("Use project specific runIde command, i.e. :plugin-toolkit:intellij-standalone:runIde")
}
Expand Down
8 changes: 0 additions & 8 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

buildscript {
// This has to be here otherwise properties are not loaded and nothing works
val props = `java.util`.Properties()
file("${project.projectDir.parent}/gradle.properties").inputStream().use { props.load(it) }
props.entries.forEach { project.extensions.add(it.key.toString(), it.value) }
}

plugins {
`kotlin-dsl`
`java-gradle-plugin`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@

package software.aws.toolkits.gradle

import org.eclipse.jgit.api.Git
import org.gradle.api.JavaVersion
import org.gradle.api.logging.Logging
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ValueSource
import org.gradle.api.provider.ValueSourceParameters
import org.gradle.process.ExecOperations
import software.aws.toolkits.gradle.intellij.IdeVersions
import java.io.ByteArrayOutputStream
import java.io.OutputStream
import java.nio.charset.Charset
import javax.inject.Inject
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion as KotlinVersionEnum

/**
Expand Down Expand Up @@ -42,21 +49,37 @@ fun<T : Any> Project.withCurrentProfileName(consumer: (String) -> T): Provider<T
}
}

fun Project.buildMetadata() =
try {
val git = Git.open(rootDir)
val currentShortHash = git.repository.findRef("HEAD").objectId.abbreviate(7).name()
val isDirty = git.status().call().hasUncommittedChanges()
abstract class GitHashValueSource : ValueSource<String, ValueSourceParameters.None> {
@get:Inject
abstract val execOperations: ExecOperations

buildString {
append(currentShortHash)
override fun obtain(): String {
return try {
val output = ByteArrayOutputStream()
execOperations.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = output
}
val currentShortHash = String(output.toByteArray(), Charset.defaultCharset())

val isDirty = execOperations.exec {
commandLine("git", "status", "-s")
standardOutput = OutputStream.nullOutputStream()
}.exitValue != 0

if (isDirty) {
append(".modified")
buildString {
append(currentShortHash)

if (isDirty) {
append(".modified")
}
}
}
} catch(e: Exception) {
logger.warn("Could not determine current commit", e)
} catch(e: Exception) {
Logging.getLogger(GitHashValueSource::class.java).warn("Could not determine current commit", e)

"unknownCommit"
"unknownCommit"
}
}
}

fun Project.buildMetadata() = providers.of(GitHashValueSource::class.java) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.gradle

import org.gradle.api.DefaultTask
import org.gradle.api.file.ArchiveOperations
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject

abstract class ExtractFlareTask @Inject constructor(
private val archiveOps: ArchiveOperations,
private var fs: FileSystemOperations
) : DefaultTask() {
@get:InputFiles
abstract val zipFiles: ConfigurableFileCollection

@get:OutputDirectory
abstract val outputDir: DirectoryProperty

@TaskAction
fun extract() {
val destDir = outputDir.get().asFile
destDir.deleteRecursively()
destDir.mkdirs()

zipFiles.filter { it.name.endsWith(".zip") }.forEach { zipFile ->
logger.info("Extracting flare from $zipFile")
fs.copy {
outputDir.file(zipFile.parentFile.name).get().asFile.createNewFile()
from(archiveOps.zipTree(zipFile)) {
include("*.js")
include("*.txt")
}
into(destDir)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import org.gradle.api.tasks.Internal
import software.aws.toolkits.gradle.changelog.GitStager

abstract class ChangeLogTask : DefaultTask() {
@Internal
protected val git = GitStager.create(project.rootDir)
fun git() = GitStager.create(project.rootDir)

@InputDirectory
val changesDirectory: DirectoryProperty = project.objects.directoryProperty().convention(project.rootProject.layout.projectDirectory.dir(".changes"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class CreateRelease @Inject constructor(projectLayout: ProjectLayout) : Cha

@Input
@Optional
val issuesUrl: Provider<String?> = project.objects.property(String::class.java).convention("https://github.com/aws/aws-toolkit-jetbrains/issues")
val issuesUrl: Provider<String> = project.objects.property(String::class.java).convention("https://github.com/aws/aws-toolkit-jetbrains/issues")

@OutputFile
val releaseFile: RegularFileProperty = project.objects.fileProperty().convention(changesDirectory.file(releaseVersion.map { "$it.json" }))
Expand All @@ -45,6 +45,7 @@ open class CreateRelease @Inject constructor(projectLayout: ProjectLayout) : Cha

val creator = ReleaseCreator(releaseEntries.files, releaseFile.get().asFile, logger)
creator.create(releaseVersion.get(), releaseDate)
val git = git()
if (git != null) {
git.stage(releaseFile.get().asFile.absoluteFile)
git.stage(nextReleaseDirectory.get().asFile.absoluteFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import software.aws.toolkits.gradle.changelog.JetBrainsWriter
abstract class GenerateChangeLog(private val shouldStage: Boolean) : ChangeLogTask() {
@Input
@Optional
val repoUrl: Provider<String?> = project.objects.property(String::class.java).convention("https://github.com/aws/aws-toolkit-jetbrains")
val repoUrl: Provider<String> = project.objects.property(String::class.java).convention("https://github.com/aws/aws-toolkit-jetbrains")

@Input
val includeUnreleased: Property<Boolean> = project.objects.property(Boolean::class.java).convention(false)
Expand Down Expand Up @@ -46,7 +46,7 @@ abstract class GenerateChangeLog(private val shouldStage: Boolean) : ChangeLogTa
generator.close()

if (shouldStage) {
git?.stage(changeLogFile.get().asFile)
git()?.stage(changeLogFile.get().asFile)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open class NewChange : ChangeLogTask() {
@TaskAction
fun create() {
val changeType = if (project.hasProperty("changeType")) {
(project.property("changeType") as? String?)?.toUpperCase()?.let { ChangeType.valueOf(it) }
(project.property("changeType") as? String?)?.uppercase()?.let { ChangeType.valueOf(it) }
} else defaultChangeType
val description = if (project.hasProperty("description")) {
project.property("description") as? String?
Expand All @@ -30,7 +30,7 @@ open class NewChange : ChangeLogTask() {
changeType != null && description != null -> createChange(changeType, description)
else -> promptForChange(input, changeType)
}
git?.stage(file)
git()?.stage(file)
}

private fun promptForChange(input: Scanner, existingChangeType: ChangeType?): File {
Expand Down
48 changes: 0 additions & 48 deletions buildSrc/src/main/kotlin/toolkit-git-secrets.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ val testJar = tasks.named<Jar>("testJar").configure {

idea {
module {
testSourceDirs = testSourceDirs + integrationTests.java.srcDirs
testResourceDirs = testResourceDirs + integrationTests.resources.srcDirs
testSources.from(integrationTests.java.srcDirs)
testResources.from(integrationTests.resources.srcDirs)
}
}
val integrationTestConfiguration: Test.() -> Unit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.tasks.BuildPluginTask
import org.jetbrains.intellij.platform.gradle.tasks.PatchPluginXmlTask
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
import software.aws.toolkits.gradle.buildMetadata
import software.aws.toolkits.gradle.intellij.IdeVersions
Expand All @@ -18,19 +15,13 @@ val toolkitVersion: String by project
// please check changelog generation logic if this format is changed
version = "$toolkitVersion.${ideProfile.shortName}"

// attach the current commit hash on local builds
if (!project.isCi()) {
val buildMetadata = buildMetadata()
tasks.withType<PatchPluginXmlTask>().configureEach {
pluginVersion.set("${project.version}+$buildMetadata")
intellijPlatform {
pluginConfiguration {
if (isCi()) {
version.set(buildMetadata().map { "${project.version}+$it" })
}
}

tasks.named<BuildPluginTask>("buildPlugin") {
archiveClassifier.set(buildMetadata)
}
}

intellijPlatform {
publishing {
val publishToken: String by project
val publishChannel: String by project
Expand Down
25 changes: 1 addition & 24 deletions buildSrc/src/main/kotlin/toolkit-testing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
id("jacoco")
id("org.gradle.test-retry")
id("com.adarshr.test-logger")
id("jacoco-report-aggregation")
}

// TODO: https://github.com/gradle/gradle/issues/15383
Expand Down Expand Up @@ -94,27 +95,3 @@ tasks.withType<Test>().configureEach {
isIncludeNoLocationClasses = true
}
}

// Jacoco configs taken from official Gradle docs: https://docs.gradle.org/current/userguide/structuring_software_products.html

// Do not generate reports for individual projects, see toolkit-jacoco-report plugin
tasks.jacocoTestReport.configure {
enabled = false
}

// Share the coverage data to be aggregated for the whole product
// this can be removed once we're using jvm-test-suites properly
configurations.register("coverageDataElements") {
isVisible = false
isCanBeResolved = false
isCanBeConsumed = true
extendsFrom(configurations.implementation.get())
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named("jacoco-coverage-data"))
}
tasks.withType<Test>().configureEach {
outgoing.artifact(extensions.getByType<JacocoTaskExtension>().destinationFile!!)
}
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ kotlin.build.report.output=file

# don't bundle Kotlin stdlib with plugin
kotlin.stdlib.default.dependency=false

org.gradle.configuration-cache=true
#org.gradle.configuration-cache.problems=warn
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 2 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -206,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
Expand Down
Loading
Loading