diff --git a/CHANGELOG.md b/CHANGELOG.md index 14bbaeea..0f0772c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.29.0 + +### Changed + +- Upgraded to Gradle 8.10.2 and Kotlin to 1.9.24. + +### Added + +- A few new helper functions are now available through extensions when applying `de.itemis.mps.gradle.common`: + - `ci` (determineCI(), isCI(), buildNumber(), registerDependencyRepositories()) + - `jdk` (determine(JavaVersion)) + - `itemis` (mbeddrGitHub(), itemisNexus()) + - `githubAuth` (user, token) + - `directories` (artifactsDir(), scriptFile(String), jnLibraryPath()) +- `de.itemis.mps.gradle.common` creates configurations for MPS (`common_mps`), language dependencies (`common_languageLibs`) and the ant lib (common_antLib) automatically. Tasks `commonCleanMps` and `commonResolveMps` are also created when you apply `de.itemis.mps.gradle.common`. +- The plugin `downloadJbr` has a new flag `defaultJavaExecutable` to set the downloaded JBR as the default Java executable. + +### Fixed + +- The `GetMpsInBrowser` task works again for all platforms including Mac Apple Silicon. + ## 1.28.0 ### Added diff --git a/api/mps-gradle-plugin.api b/api/mps-gradle-plugin.api index f5f9d1b5..891f09ba 100644 --- a/api/mps-gradle-plugin.api +++ b/api/mps-gradle-plugin.api @@ -30,31 +30,32 @@ public class de/itemis/mps/gradle/BuildLanguages : de/itemis/mps/gradle/RunAntSc public fun ()V } -public class de/itemis/mps/gradle/BundleMacosJdk : org/gradle/api/DefaultTask, groovy/lang/GroovyObject { - public static synthetic field __$stMC Z - protected synthetic fun $getStaticMetaClass ()Lgroovy/lang/MetaClass; +public class de/itemis/mps/gradle/BundleMacosJdk : org/gradle/api/DefaultTask { + public field jdk Ljava/io/File; + public field outputFile Ljava/io/File; + public field rcpArtifact Ljava/io/File; public fun ()V - public fun build ()Ljava/lang/Object; - public fun getJdk ()Ljava/io/File; - public fun getJdkDirname ()Ljava/lang/String; - public fun getMetaClass ()Lgroovy/lang/MetaClass; - public fun getOutputFile ()Ljava/io/File; - public fun getRcpArtifact ()Ljava/io/File; - public fun setJdk (Ljava/lang/Object;)Ljava/lang/Object; - public fun setJdkDependency (Ljava/lang/Object;)Ljava/lang/Object; - public fun setJdkDirname (Ljava/lang/String;)Ljava/lang/Object; - public fun setMetaClass (Lgroovy/lang/MetaClass;)V - public fun setOutputFile (Ljava/lang/Object;)Ljava/lang/Object; - public fun setRcpArtifact (Ljava/lang/Object;)Ljava/lang/Object; + public final fun build ()V + public final fun getJdk ()Ljava/io/File; + public final fun getJdkDirname ()Ljava/lang/String; + public final fun getOutputFile ()Ljava/io/File; + public final fun getRcpArtifact ()Ljava/io/File; + public final fun setJdk (Ljava/io/File;)V + public final fun setJdkDependency (Ljava/lang/Object;)V + public final fun setJdkDirname (Ljava/lang/String;)V + public final fun setOutputFile (Ljava/io/File;)V + public final fun setOutputFile (Ljava/lang/Object;)V + public final fun setRcpArtifact (Ljava/io/File;)V +} + +public final class de/itemis/mps/gradle/BundledScripts { + public static final field Companion Lde/itemis/mps/gradle/BundledScripts$Companion; + public fun ()V + public static final fun extractScriptsToDir (Ljava/io/File;[Ljava/lang/String;)V } -public class de/itemis/mps/gradle/BundledScripts : groovy/lang/GroovyObject { - public static synthetic field __$stMC Z - protected synthetic fun $getStaticMetaClass ()Lgroovy/lang/MetaClass; - public fun ()V - public static fun extractScriptsToDir (Ljava/io/File;[Ljava/lang/String;)V - public fun getMetaClass ()Lgroovy/lang/MetaClass; - public fun setMetaClass (Lgroovy/lang/MetaClass;)V +public final class de/itemis/mps/gradle/BundledScripts$Companion { + public final fun extractScriptsToDir (Ljava/io/File;[Ljava/lang/String;)V } public final class de/itemis/mps/gradle/CommonKt { @@ -72,28 +73,44 @@ public final class de/itemis/mps/gradle/CommonPlugin : org/gradle/api/Plugin { public fun apply (Lorg/gradle/api/Project;)V } -public class de/itemis/mps/gradle/CreateDmg : org/gradle/api/DefaultTask, groovy/lang/GroovyObject { - public static synthetic field __$stMC Z - protected synthetic fun $getStaticMetaClass ()Lgroovy/lang/MetaClass; +public abstract class de/itemis/mps/gradle/Common_gradle$CI { + public fun (Lorg/gradle/api/Project;)V + public final fun buildNumber ()I + public final fun determineCI ()V + public final fun get_project ()Lorg/gradle/api/Project; + public final fun isCI ()Ljava/lang/Object; + public final fun registerDependencyRepositories (Ljava/util/ArrayList;)V +} + +public abstract class de/itemis/mps/gradle/Common_gradle$Directories { + public fun (Lorg/gradle/api/Project;)V + public final fun artifactsDir ()Ljava/io/File; + public final fun get_project ()Lorg/gradle/api/Project; + public final fun jnLibraryPath ()Ljava/io/File; + public final fun scriptFile (Ljava/lang/String;)Ljava/io/File; +} + +public abstract class de/itemis/mps/gradle/Common_gradle$GitHubAuth { + public fun (Lorg/gradle/api/Project;)V + public final fun getToken ()Ljava/lang/String; + public final fun getUser ()Ljava/lang/String; +} + +public abstract class de/itemis/mps/gradle/Common_gradle$Itemis { public fun ()V - public fun build ()Ljava/lang/Object; - public fun getBackgroundImage ()Ljava/io/File; - public fun getDmgFile ()Ljava/io/File; - public fun getJdk ()Ljava/io/File; - public fun getMetaClass ()Lgroovy/lang/MetaClass; - public fun getRcpArtifact ()Ljava/io/File; - public fun getSignIdentity ()Ljava/lang/String; - public fun getSignKeyChain ()Ljava/io/File; - public fun getSignKeyChainPassword ()Ljava/lang/String; - public fun setBackgroundImage (Ljava/lang/Object;)Ljava/lang/Object; - public fun setDmgFile (Ljava/lang/Object;)Ljava/lang/Object; - public fun setJdk (Ljava/lang/Object;)Ljava/lang/Object; - public fun setJdkDependency (Ljava/lang/Object;)Ljava/lang/Object; - public fun setMetaClass (Lgroovy/lang/MetaClass;)V - public fun setRcpArtifact (Ljava/lang/Object;)Ljava/lang/Object; - public fun setSignIdentity (Ljava/lang/String;)V - public fun setSignKeyChain (Ljava/lang/Object;)Ljava/lang/Object; - public fun setSignKeyChainPassword (Ljava/lang/String;)V + public final fun itemisNexus ()Ljava/lang/String; + public final fun mbeddrGitHub ()Ljava/lang/String; +} + +public abstract class de/itemis/mps/gradle/Common_gradle$JDK { + public fun (Lorg/gradle/api/Project;)V + public final fun determine (Lorg/gradle/api/JavaVersion;)V + public final fun get_project ()Lorg/gradle/api/Project; +} + +public final class de/itemis/mps/gradle/Common_gradle$inlined$sam$i$org_gradle_api_Action$0 : org/gradle/api/Action { + public fun (Lkotlin/jvm/functions/Function1;)V + public final synthetic fun execute (Ljava/lang/Object;)V } public final class de/itemis/mps/gradle/EnvironmentKind : java/lang/Enum { @@ -118,15 +135,23 @@ public class de/itemis/mps/gradle/GenerateLibrariesXml : org/gradle/api/DefaultT public fun setOverrides (Ljava/lang/Object;)V } -public class de/itemis/mps/gradle/GetMpsInBrowser : org/gradle/api/DefaultTask, groovy/lang/GroovyObject { - public static synthetic field __$stMC Z - protected synthetic fun $getStaticMetaClass ()Lgroovy/lang/MetaClass; +public class de/itemis/mps/gradle/GetMpsInBrowser : org/gradle/api/DefaultTask { public fun ()V - public fun build ()Ljava/lang/Object; - public fun getMetaClass ()Lgroovy/lang/MetaClass; - public fun getVersion ()Ljava/lang/String; - public fun setMetaClass (Lgroovy/lang/MetaClass;)V - public fun setVersion (Ljava/lang/String;)Ljava/lang/Object; + public final fun build ()V + public final fun getVersion ()Ljava/lang/String; + public final fun setVersion (Ljava/lang/String;)V +} + +public final class de/itemis/mps/gradle/MPSVersion { + public static final field Companion Lde/itemis/mps/gradle/MPSVersion$Companion; + public synthetic fun (Lnet/swiftzer/semver/SemVer;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getVersion ()Lnet/swiftzer/semver/SemVer; + public final fun toMavenSnapshot ()Ljava/lang/String; + public fun toString ()Ljava/lang/String; +} + +public final class de/itemis/mps/gradle/MPSVersion$Companion { + public final fun parse (Ljava/lang/String;)Lde/itemis/mps/gradle/MPSVersion; } public final class de/itemis/mps/gradle/Macro { @@ -159,14 +184,10 @@ public final class de/itemis/mps/gradle/Plugin { public fun toString ()Ljava/lang/String; } -public class de/itemis/mps/gradle/Pom : groovy/lang/GroovyObject { - public static synthetic field __$stMC Z - protected synthetic fun $getStaticMetaClass ()Lgroovy/lang/MetaClass; +public final class de/itemis/mps/gradle/Pom { public fun ()V - public fun getMetaClass ()Lgroovy/lang/MetaClass; - public fun setMetaClass (Lgroovy/lang/MetaClass;)V - public fun withDep (Lorg/gradle/api/publish/maven/MavenPom;Lorg/gradle/api/artifacts/Configuration;)Ljava/lang/Object; - public fun withProvidedDep (Lorg/gradle/api/publish/maven/MavenPom;Lorg/gradle/api/artifacts/Configuration;)Ljava/lang/Object; + public final fun withDep (Lorg/gradle/api/publish/maven/MavenPom;Lorg/gradle/api/artifacts/Configuration;)V + public final fun withProvidedDep (Lorg/gradle/api/publish/maven/MavenPom;Lorg/gradle/api/artifacts/Configuration;)V } public class de/itemis/mps/gradle/RunAntScript : org/gradle/api/DefaultTask { @@ -197,12 +218,43 @@ public class de/itemis/mps/gradle/TestLanguages : de/itemis/mps/gradle/RunAntScr public fun ()V } +public class de/itemis/mps/gradle/de/itemis/mps/gradle/CreateDmg : org/gradle/api/DefaultTask { + public field backgroundImage Ljava/io/File; + public field dmgFile Ljava/io/File; + public field jdk Ljava/io/File; + public field rcpArtifact Ljava/io/File; + public fun ()V + public final fun build ()V + public final fun getBackgroundImage ()Ljava/io/File; + public final fun getDmgFile ()Ljava/io/File; + public final fun getJdk ()Ljava/io/File; + public final fun getRcpArtifact ()Ljava/io/File; + public final fun getSignIdentity ()Ljava/lang/String; + public final fun getSignKeyChain ()Ljava/io/File; + public final fun getSignKeyChainPassword ()Ljava/lang/String; + public final fun setBackgroundImage (Ljava/io/File;)V + public final fun setBackgroundImage (Ljava/lang/Object;)V + public final fun setDmgFile (Ljava/io/File;)V + public final fun setDmgFile (Ljava/lang/Object;)V + public final fun setJdk (Ljava/io/File;)V + public final fun setJdk (Ljava/lang/Object;)V + public final fun setJdkDependency (Ljava/lang/Object;)V + public final fun setRcpArtifact (Ljava/io/File;)V + public final fun setRcpArtifact (Ljava/lang/Object;)V + public final fun setSignIdentity (Ljava/lang/String;)V + public final fun setSignKeyChain (Ljava/io/File;)V + public final fun setSignKeyChain (Ljava/lang/Object;)V + public final fun setSignKeyChainPassword (Ljava/lang/String;)V +} + public class de/itemis/mps/gradle/downloadJBR/DownloadJbrConfiguration { public field jbrVersion Ljava/lang/String; public fun (Lorg/gradle/api/model/ObjectFactory;)V + public final fun getDefaultJavaExecutable ()Z public final fun getDistributionType ()Ljava/lang/String; public final fun getDownloadDir ()Ljava/io/File; public final fun getJbrVersion ()Ljava/lang/String; + public final fun setDefaultJavaExecutable (Z)V public final fun setDistributionType (Ljava/lang/String;)V public final fun setDownloadDir (Ljava/io/File;)V public final fun setJbrVersion (Ljava/lang/String;)V diff --git a/build.gradle.kts b/build.gradle.kts index b3944f6d..d7db10c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,20 +11,19 @@ buildscript { } } -val kotlinApiVersion by extra { "1.7" } -val kotlinVersion by extra { "$kotlinApiVersion.10" } - +val kotlinApiVersion: String by project +val kotlinVersion: String by project plugins { groovy `java-gradle-plugin` `kotlin-dsl` `maven-publish` - kotlin("jvm") version "1.7.10" - id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" + kotlin("jvm") + id("org.jetbrains.kotlinx.binary-compatibility-validator") } -val baseVersion = "1.28.0" +val baseVersion = "1.29.0" group = "de.itemis.mps" @@ -60,8 +59,8 @@ dependencyLocking { dependencies { api("de.itemis.mps.gradle:git-based-versioning") implementation(kotlin("stdlib", version = kotlinVersion)) - implementation("net.swiftzer.semver:semver:1.1.2") - implementation("de.itemis.mps.build-backends:launcher:2.4.0.+") + implementation("net.swiftzer.semver:semver:2.0.0") + implementation("de.itemis.mps.build-backends:launcher:2.5.+") testImplementation("junit:junit:4.13.2") } diff --git a/buildscript-gradle.lockfile b/buildscript-gradle.lockfile index 77a8d73e..da11ca4a 100644 --- a/buildscript-gradle.lockfile +++ b/buildscript-gradle.lockfile @@ -1,42 +1,39 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.googlecode.java-diff-utils:diffutils:1.3.0=classpath -org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:4.3.1=classpath -org.gradle.kotlin:gradle-kotlin-dsl-plugins:4.3.1=classpath +io.github.java-diff-utils:java-diff-utils:4.12=classpath +org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:4.5.0=classpath +org.gradle.kotlin:gradle-kotlin-dsl-plugins:4.5.0=classpath org.jetbrains.intellij.deps:trove4j:1.0.20200330=classpath -org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.10=classpath -org.jetbrains.kotlin:kotlin-android-extensions:1.9.22=classpath -org.jetbrains.kotlin:kotlin-assignment:1.9.22=classpath -org.jetbrains.kotlin:kotlin-build-tools-api:1.9.22=classpath -org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.22=classpath -org.jetbrains.kotlin:kotlin-compiler-runner:1.9.22=classpath -org.jetbrains.kotlin:kotlin-daemon-client:1.9.22=classpath -org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.22=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.22=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.22=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.22=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.22=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.22=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22=classpath -org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.22=classpath -org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.22=classpath -org.jetbrains.kotlin:kotlin-native-utils:1.9.22=classpath -org.jetbrains.kotlin:kotlin-project-model:1.9.22=classpath -org.jetbrains.kotlin:kotlin-sam-with-receiver:1.9.22=classpath -org.jetbrains.kotlin:kotlin-scripting-common:1.9.22=classpath -org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.22=classpath -org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.22=classpath -org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.22=classpath -org.jetbrains.kotlin:kotlin-stdlib:1.9.22=classpath -org.jetbrains.kotlin:kotlin-tooling-core:1.9.22=classpath -org.jetbrains.kotlin:kotlin-util-io:1.9.22=classpath -org.jetbrains.kotlin:kotlin-util-klib:1.9.22=classpath -org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin:0.13.2=classpath -org.jetbrains.kotlinx:binary-compatibility-validator:0.13.2=classpath +org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.24=classpath +org.jetbrains.kotlin:kotlin-android-extensions:1.9.24=classpath +org.jetbrains.kotlin:kotlin-assignment:1.9.24=classpath +org.jetbrains.kotlin:kotlin-build-tools-api:1.9.24=classpath +org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24=classpath +org.jetbrains.kotlin:kotlin-compiler-runner:1.9.24=classpath +org.jetbrains.kotlin:kotlin-daemon-client:1.9.24=classpath +org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.24=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.24=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.24=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.24=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.24=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.24=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24=classpath +org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.24=classpath +org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.24=classpath +org.jetbrains.kotlin:kotlin-native-utils:1.9.24=classpath +org.jetbrains.kotlin:kotlin-project-model:1.9.24=classpath +org.jetbrains.kotlin:kotlin-sam-with-receiver:1.9.24=classpath +org.jetbrains.kotlin:kotlin-scripting-common:1.9.24=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.24=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.24=classpath +org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.24=classpath +org.jetbrains.kotlin:kotlin-stdlib:1.9.24=classpath +org.jetbrains.kotlin:kotlin-tooling-core:1.9.24=classpath +org.jetbrains.kotlin:kotlin-util-io:1.9.24=classpath +org.jetbrains.kotlin:kotlin-util-klib:1.9.24=classpath +org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin:0.16.3=classpath +org.jetbrains.kotlinx:binary-compatibility-validator:0.16.3=classpath org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath -org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.6.2=classpath org.jetbrains:annotations:13.0=classpath -org.ow2.asm:asm-tree:9.2=classpath -org.ow2.asm:asm:9.2=classpath empty= diff --git a/docs/plugins/download-jbr.md b/docs/plugins/download-jbr.md index ea295d73..19adbffe 100644 --- a/docs/plugins/download-jbr.md +++ b/docs/plugins/download-jbr.md @@ -30,6 +30,7 @@ repositories { downloadJbr { jbrVersion = "11_0_6-b520.66" + defaultJavaExecutable.set(true) // optional } ``` @@ -45,6 +46,7 @@ repositories { downloadJbr { jbrVersion = '11_0_6-b520.66' + defaultJavaExecutable.set(true) // optional } ``` @@ -52,6 +54,7 @@ downloadJbr { * `jbrVersion` - version of the JBR to download. While this supports maven version selectors we highly recommend not using wildcards like `*` or `+` in there for reproducible builds. +* `defaultJavaExecutable` - set the downloaded JBR as the default Java executable * `distributionType` - optional distribution type for the JBR to use. Will default to `jbr_jcef` if omitted. * `downloadDir` - optional directory where the downloaded JBR is downloaded and extracted to. The plugin defaults to `build/jbrDownload`. diff --git a/git-based-versioning/src/main/groovy/de/itemis/mps/gradle/GitBasedVersioning.groovy b/git-based-versioning/src/main/groovy/de/itemis/mps/gradle/GitBasedVersioning.groovy index c00c45c9..523fddf7 100644 --- a/git-based-versioning/src/main/groovy/de/itemis/mps/gradle/GitBasedVersioning.groovy +++ b/git-based-versioning/src/main/groovy/de/itemis/mps/gradle/GitBasedVersioning.groovy @@ -75,17 +75,18 @@ class GitBasedVersioning { getVersion(branch, major, minor, getGitCommitCount()) } - static String getVersionWithCount(String major, String minor, int count) { + static String getVersionWithCount(String major, String minor, Integer count) { getVersion(getGitBranch(), major, minor, count) } - static String getVersionWithBugfixAndCount(String major, String minor, String bugfix, int count) { + static String getVersionWithBugfixAndCount(String major, String minor, String bugfix, Integer count) { getVersion(getGitBranch(), major, minor, bugfix, count) } - static String getVersion(String branch, String major, String minor, String bugfix = "", int count) { + static String getVersion(String branch, String major, String minor, String bugfix = "", Integer count) { def hash = getGitShortCommitHash() - def baseVersion = bugfix.isEmpty() ? "$major.$minor.$count.$hash" : "$major.$minor.$bugfix.$count.$hash" + def countStr = count != null ? ".$count": "" + def baseVersion = bugfix.isEmpty() ? "$major.$minor${countStr}.$hash" : "$major.$minor.$bugfix${countStr}.$hash" if (branch == 'master' || branch == 'main' || branch == 'HEAD' /*this happens in detached head situations*/) { return baseVersion } @@ -100,12 +101,12 @@ class GitBasedVersioning { * @param minor * @return */ - static String getVersionWithoutMaintenancePrefix(String major, String minor) { + static String getVersionWithoutMaintenancePrefix(String major, String minor, Integer count = null) { def branch = getGitBranch() if (branch.startsWith("maintenance") || branch.startsWith("mps")) { - getVersion("HEAD", major, minor) + getVersion("HEAD", major, minor, count != null? count: getGitCommitCount()) } else { - getVersion(major, minor) + getVersion(getGitBranch(), major, minor, count != null? count: getGitCommitCount()) } } } diff --git a/gradle.lockfile b/gradle.lockfile index 1c904a4b..3d639465 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -1,31 +1,39 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -de.itemis.mps.build-backends:launcher:2.4.0.95.a261d1d=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +de.itemis.mps.build-backends:launcher:2.5.2.107.def8e1d=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath junit:junit:4.13.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath -net.swiftzer.semver:semver:1.1.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +net.swiftzer.semver:semver-jvm:2.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +net.swiftzer.semver:semver:2.0.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath -org.jetbrains.kotlin:kotlin-assignment-compiler-plugin-embeddable:1.9.22=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest -org.jetbrains.kotlin:kotlin-build-common:1.9.22=kotlinBuildToolsApiClasspath -org.jetbrains.kotlin:kotlin-build-tools-api:1.9.22=kotlinBuildToolsApiClasspath -org.jetbrains.kotlin:kotlin-build-tools-impl:1.9.22=kotlinBuildToolsApiClasspath -org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.22=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath -org.jetbrains.kotlin:kotlin-compiler-runner:1.9.22=kotlinBuildToolsApiClasspath -org.jetbrains.kotlin:kotlin-daemon-client:1.9.22=kotlinBuildToolsApiClasspath -org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.22=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath -org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.9.22=kotlinKlibCommonizerClasspath +org.jetbrains.kotlin:kotlin-assignment-compiler-plugin-embeddable:1.9.24=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest +org.jetbrains.kotlin:kotlin-build-common:1.9.24=kotlinBuildToolsApiClasspath +org.jetbrains.kotlin:kotlin-build-tools-api:1.9.24=kotlinBuildToolsApiClasspath +org.jetbrains.kotlin:kotlin-build-tools-impl:1.9.24=kotlinBuildToolsApiClasspath +org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath +org.jetbrains.kotlin:kotlin-compiler-runner:1.9.24=kotlinBuildToolsApiClasspath +org.jetbrains.kotlin:kotlin-daemon-client:1.9.24=kotlinBuildToolsApiClasspath +org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.24=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath +org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.9.24=kotlinKlibCommonizerClasspath +org.jetbrains.kotlin:kotlin-metadata-jvm:2.0.0=bcv-rt-jvm-cp-resolver +org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.20=kotlinNativeBundleConfiguration org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath -org.jetbrains.kotlin:kotlin-reflect:1.9.22=compileClasspath,compileOnlyDependenciesMetadata,embeddedKotlin,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath -org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin-embeddable:1.9.22=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest -org.jetbrains.kotlin:kotlin-script-runtime:1.9.22=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath -org.jetbrains.kotlin:kotlin-scripting-common:1.9.22=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest -org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.22=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest -org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.22=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest -org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.22=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest -org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=implementationDependenciesMetadata,runtimeClasspath -org.jetbrains.kotlin:kotlin-stdlib:1.7.10=implementationDependenciesMetadata,runtimeClasspath -org.jetbrains.kotlin:kotlin-stdlib:1.9.22=compileClasspath,compileOnlyDependenciesMetadata,embeddedKotlin,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-reflect:1.9.24=compileClasspath,compileOnlyDependenciesMetadata,embeddedKotlin,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin-embeddable:1.9.24=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest +org.jetbrains.kotlin:kotlin-script-runtime:1.9.24=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath +org.jetbrains.kotlin:kotlin-scripting-common:1.9.24=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest +org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.24=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest +org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.24=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest +org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.24=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest +org.jetbrains.kotlin:kotlin-stdlib-common:1.9.24=implementationDependenciesMetadata,runtimeClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib:1.9.24=compileClasspath,compileOnlyDependenciesMetadata,embeddedKotlin,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib:2.0.0=bcv-rt-jvm-cp-resolver org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=kotlinBuildToolsApiClasspath -org.jetbrains:annotations:13.0=compileClasspath,embeddedKotlin,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -empty=annotationProcessor,apiDependenciesMetadata,intransitiveDependenciesMetadata,kotlinCompilerPluginClasspath,kotlinNativeCompilerPluginClasspath,kotlinScriptDef,kotlinScriptDefExtensions,mps,runtimeOnlyDependenciesMetadata,testAnnotationProcessor,testApiDependenciesMetadata,testCompileOnlyDependenciesMetadata,testIntransitiveDependenciesMetadata,testKotlinScriptDef,testKotlinScriptDefExtensions,testRuntimeOnlyDependenciesMetadata +org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.3=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.3=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3=implementationDependenciesMetadata,runtimeClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +org.jetbrains:annotations:13.0=bcv-rt-jvm-cp-resolver,compileClasspath,embeddedKotlin,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.ow2.asm:asm-tree:9.6=bcv-rt-jvm-cp-resolver +org.ow2.asm:asm:9.6=bcv-rt-jvm-cp-resolver +empty=annotationProcessor,apiDependenciesMetadata,intransitiveDependenciesMetadata,kotlinCompilerPluginClasspath,kotlinNativeCompilerPluginClasspath,kotlinScriptDef,kotlinScriptDefExtensions,mps,testAnnotationProcessor,testApiDependenciesMetadata,testCompileOnlyDependenciesMetadata,testIntransitiveDependenciesMetadata,testKotlinScriptDef,testKotlinScriptDefExtensions diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..2a65d382 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +kotlinApiVersion=1.8 +kotlinVersion=1.9.24 +kotlinDSLVersion=4.5.0 +binaryCompatibilityValidator=0.16.3 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136..a4b76b95 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138..df97d72b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf13..f5feea6d 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -84,7 +86,8 @@ 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30db..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/settings.gradle.kts b/settings.gradle.kts index a400c38f..5fa88400 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,15 @@ pluginManagement { includeBuild("git-based-versioning") + + val kotlinVersion: String by settings + val kotlinDSLVersion: String by settings + val binaryCompatibilityValidator: String by settings + + plugins { + kotlin("jvm") version kotlinVersion + `kotlin-dsl` version kotlinDSLVersion + id("org.jetbrains.kotlinx.binary-compatibility-validator") version binaryCompatibilityValidator + } } plugins { diff --git a/src/main/groovy/de/itemis/mps/gradle/BundleMacosJdk.groovy b/src/main/groovy/de/itemis/mps/gradle/BundleMacosJdk.groovy deleted file mode 100644 index 1553c55a..00000000 --- a/src/main/groovy/de/itemis/mps/gradle/BundleMacosJdk.groovy +++ /dev/null @@ -1,76 +0,0 @@ -package de.itemis.mps.gradle - -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.artifacts.Dependency -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction - -class BundleMacosJdk extends DefaultTask { - @InputFile - File rcpArtifact - - @Optional @Input - String jdkDirname = "jre" - - @InputFile - File jdk - - @OutputFile - File outputFile - - def setRcpArtifact(Object file) { - this.rcpArtifact = project.file(file) - } - - def setJdkDirname(String dirname) { - this.jdkDirname = dirname - } - - def setJdk(Object file) { - this.jdk = project.file(file) - } - - /** - * Sets the {@link #jdk} property from a dependency, given as either a {@link Dependency} object or in dependency - * notation. - */ - def setJdkDependency(Object jdkDependency) { - Dependency dep = project.dependencies.create(jdkDependency) - def files = project.configurations.detachedConfiguration(dep).resolve() - if (files.size() != 1) { - throw new GradleException( - "Expected a single file for jdkDependency '$jdkDependency', got ${files.size()} files") - } - this.jdk = files.first() - } - - def setOutputFile(Object file) { - this.outputFile = project.file(file) - } - - @TaskAction - def build() { - project.logger.lifecycle("The jdkDirname: ${jdkDirname}") - File scriptsDir = File.createTempDir() - File tmpDir = File.createTempDir() - try { - String scriptName = 'bundle_macos_jdk.sh' - BundledScripts.extractScriptsToDir(scriptsDir, scriptName) - project.exec { - executable new File(scriptsDir, scriptName) - args rcpArtifact, tmpDir, jdkDirname, jdk, outputFile - workingDir scriptsDir - } - } finally { - // Do not use File.deleteDir() because it follows symlinks! - // (e.g. the symlink to /Applications inside tmpDir) - project.exec { - commandLine 'rm', '-rf', scriptsDir, tmpDir - } - } - } -} diff --git a/src/main/groovy/de/itemis/mps/gradle/BundledScripts.groovy b/src/main/groovy/de/itemis/mps/gradle/BundledScripts.groovy deleted file mode 100644 index 6ca62f1e..00000000 --- a/src/main/groovy/de/itemis/mps/gradle/BundledScripts.groovy +++ /dev/null @@ -1,26 +0,0 @@ -package de.itemis.mps.gradle - -import org.gradle.api.GradleException - -import java.nio.file.Files -import java.nio.file.attribute.PosixFilePermissions - -class BundledScripts { - static void extractScriptsToDir(File dir, String... scriptNames) { - def rwxPermissions = PosixFilePermissions.fromString("rwx------") - - for (name in scriptNames) { - File file = new File(dir, name) - if (!file.parentFile.isDirectory() && ! file.parentFile.mkdirs()) { - throw new GradleException("Could not create directory " + file.parentFile) - } - InputStream resourceStream = BundledScripts.class.getResourceAsStream(name) - if (resourceStream == null) { - throw new IllegalArgumentException("Resource ${name} was not found") - } - - resourceStream.withStream { is -> file.newOutputStream().withStream { os -> os << is } } - Files.setPosixFilePermissions(file.toPath(), rwxPermissions) - } - } -} diff --git a/src/main/groovy/de/itemis/mps/gradle/CreateDmg.groovy b/src/main/groovy/de/itemis/mps/gradle/CreateDmg.groovy deleted file mode 100644 index b0dc1957..00000000 --- a/src/main/groovy/de/itemis/mps/gradle/CreateDmg.groovy +++ /dev/null @@ -1,106 +0,0 @@ -package de.itemis.mps.gradle - -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.artifacts.Dependency -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction -import org.gradle.api.tasks.Optional - -class CreateDmg extends DefaultTask { - @InputFile - File rcpArtifact - - @InputFile - File backgroundImage - - @InputFile - File jdk - - @OutputFile - File dmgFile - - @Optional @Input - String signKeyChainPassword - - @Optional @Input - String signIdentity - - @InputFile @Optional - File signKeyChain - - def setSignKeyChain(Object file) { - this.signKeyChain = project.file(file) - } - - def setRcpArtifact(Object file) { - this.rcpArtifact = project.file(file) - } - - def setBackgroundImage(Object file) { - this.backgroundImage = project.file(file) - } - - def setJdk(Object file) { - this.jdk = project.file(file) - } - - /** - * Sets the {@link #jdk} property from a dependency, given as either a {@link Dependency} object or in dependency - * notation. - */ - def setJdkDependency(Object jdkDependency) { - Dependency dep = project.dependencies.create(jdkDependency) - def files = project.configurations.detachedConfiguration(dep).resolve() - if (files.size() != 1) { - throw new GradleException( - "Expected a single file for jdkDependency '$jdkDependency', got ${files.size()} files") - } - this.jdk = files.first() - } - - def setDmgFile(Object file) { - this.dmgFile = project.file(file) - if (dmgFile != null && !dmgFile.name.endsWith(".dmg")) { - throw new GradleException("Value of dmgFile must end with .dmg but was $dmgFile") - } - } - - @TaskAction - def build() { - String[] scripts = ['mpssign.sh', 'mpsdmg.sh', 'mpsdmg.pl', - 'Mac/Finder/DSStore/BuddyAllocator.pm', 'Mac/Finder/DSStore.pm'] - File scriptsDir = File.createTempDir() - File dmgDir = File.createTempDir() - def signingInfo = [signKeyChainPassword, signKeyChain, signIdentity] - try { - BundledScripts.extractScriptsToDir(scriptsDir, scripts) - project.exec { - executable new File(scriptsDir, 'mpssign.sh') - - if(signingInfo.every {it != null}) { - args '-r', rcpArtifact, '-o', dmgDir, '-j', jdk, '-p', signKeyChainPassword, '-k', signKeyChain, '-i', signIdentity - }else if (signingInfo.every {it == null}){ - args '-r', rcpArtifact, '-o', dmgDir, '-j', jdk - }else{ - throw new IllegalArgumentException("Not all signing paramters set. signKeyChain: ${getSigningInfo[1]}, signIdentity: ${getSigningInfo[2]} and signKeyChainPassword needs to be set. ") - } - workingDir scriptsDir - } - project.exec { - executable new File(scriptsDir, 'mpsdmg.sh') - args dmgDir, dmgFile, backgroundImage - workingDir scriptsDir - } - } finally { - // Do not use File.deleteDir() because it follows symlinks! - // (e.g. the symlink to /Applications inside dmgDir) - project.exec { - commandLine 'rm', '-rf', scriptsDir, dmgDir - } - } - } - -} diff --git a/src/main/groovy/de/itemis/mps/gradle/GetMpsInBrowser.groovy b/src/main/groovy/de/itemis/mps/gradle/GetMpsInBrowser.groovy deleted file mode 100644 index 252f91b9..00000000 --- a/src/main/groovy/de/itemis/mps/gradle/GetMpsInBrowser.groovy +++ /dev/null @@ -1,54 +0,0 @@ -package de.itemis.mps.gradle - -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.TaskAction -import org.apache.tools.ant.taskdefs.condition.Os - -import java.awt.Desktop - -class GetMpsInBrowser extends DefaultTask { - - @Input - String version - - def setVersion(String version) { - this.version = version - } - - private String getMajorPart() { - def split = version.split("\\.") - if (split.length == 2) { - return version - } - - return split.take(2).join(".") - } - - private URI getDownloadUrl() { - def major = getMajorPart() - - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - return new URI("https://download.jetbrains.com/mps/${major}/MPS-${version}.exe") - } else if (Os.isFamily(Os.FAMILY_MAC)) { - return new URI("https://download.jetbrains.com/mps/${major}/MPS-${version}-macos-jdk-bundled.dmg") - } else if (Os.isFamily(Os.FAMILY_UNIX)) { - return new URI("https://download.jetbrains.com/mps/${major}/MPS-${version}.tar.gz") - } else { - print "Warning: could not determine OS downloading generic distribution" - return new URI("http://download.jetbrains.com/mps/${major}/MPS-${version}.zip") - } - - } - - @TaskAction - def build() { - - if (Desktop.isDesktopSupported()) { - Desktop.getDesktop().browse(getDownloadUrl()) - } else { - throw new GradleException("this task is not supported in headless mode") - } - } -} diff --git a/src/main/groovy/de/itemis/mps/gradle/Pom.groovy b/src/main/groovy/de/itemis/mps/gradle/Pom.groovy deleted file mode 100644 index 89bd350b..00000000 --- a/src/main/groovy/de/itemis/mps/gradle/Pom.groovy +++ /dev/null @@ -1,43 +0,0 @@ -package de.itemis.mps.gradle - -import org.gradle.api.artifacts.Configuration -import org.gradle.api.publish.maven.MavenPom - -class Pom { - - /** - * Add all top level dependencies of a configuration to a pom - * @param pom the POM node where to add the dependencies - * @param config the configuration where to get the dependencies from - */ - def withDep(MavenPom pom, Configuration config) { - pom.withXml { - def dependenciesNode = asNode().appendNode('dependencies') - config.resolvedConfiguration.firstLevelModuleDependencies.each { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.moduleGroup) - dependencyNode.appendNode('artifactId', it.moduleName) - dependencyNode.appendNode('version', it.moduleVersion) - dependencyNode.appendNode('type', it.moduleArtifacts[0].type) - } - } - } - /** - * Add all top level dependencies of a configuration to a pom with provided scope - * @param pom the POM node where to add the dependencies - * @param config the configuration where to get the dependencies from - */ - def withProvidedDep(MavenPom pom, Configuration config) { - pom.withXml { - def dependenciesNode = asNode().appendNode('dependencies') - config.resolvedConfiguration.firstLevelModuleDependencies.each { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.moduleGroup) - dependencyNode.appendNode('artifactId', it.moduleName) - dependencyNode.appendNode('version', it.moduleVersion) - dependencyNode.appendNode('type', it.moduleArtifacts[0].type) - dependencyNode.appendNode('scope', 'provided') - } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/de/itemis/mps/gradle/BundleMacosJdk.kt b/src/main/kotlin/de/itemis/mps/gradle/BundleMacosJdk.kt new file mode 100644 index 00000000..c4dbf557 --- /dev/null +++ b/src/main/kotlin/de/itemis/mps/gradle/BundleMacosJdk.kt @@ -0,0 +1,66 @@ +package de.itemis.mps.gradle + +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.artifacts.Dependency +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction +import java.io.File +import kotlin.io.path.createTempDirectory + +open class BundleMacosJdk : DefaultTask() { + @InputFile + lateinit var rcpArtifact: File + + @Optional @Input + var jdkDirname: String = "jre" + + @InputFile + lateinit var jdk: File + + @OutputFile + lateinit var outputFile: File + + /** + * Sets the [jdk] property from a dependency, given as either a [Dependency] object or in dependency notation. + */ + fun setJdkDependency(jdkDependency: Any) { + val dep: Dependency = project.dependencies.create(jdkDependency) + val files = project.configurations.detachedConfiguration(dep).resolve() + if (files.size != 1) { + throw GradleException( + "Expected a single file for jdkDependency '$jdkDependency', got ${files.size} files" + ) + } + this.jdk = files.first() + } + + fun setOutputFile(file: Any) { + this.outputFile = project.file(file) + } + + @TaskAction + fun build() { + project.logger.lifecycle("The jdkDirname: $jdkDirname") + val scriptsDir = createTempDirectory().toFile() + val tmpDir = createTempDirectory().toFile() + try { + val scriptName = "bundle_macos_jdk.sh" + BundledScripts.extractScriptsToDir(scriptsDir, scriptName) + project.exec { + executable = File(scriptsDir, scriptName).absolutePath + args = listOf(rcpArtifact.toString(), tmpDir.toString(), jdkDirname.toString(), jdk.toString(), outputFile.toString()) + workingDir = scriptsDir + } + } finally { + // Do not use File.deleteDir() because it follows symlinks! + // (e.g. the symlink to /Applications inside tmpDir) + project.exec { + commandLine("rm", "-rf", scriptsDir.absolutePath, tmpDir.absolutePath) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/de/itemis/mps/gradle/BundleScripts.kt b/src/main/kotlin/de/itemis/mps/gradle/BundleScripts.kt new file mode 100644 index 00000000..0768466a --- /dev/null +++ b/src/main/kotlin/de/itemis/mps/gradle/BundleScripts.kt @@ -0,0 +1,32 @@ +package de.itemis.mps.gradle + +import org.gradle.api.GradleException +import java.io.File +import java.io.InputStream +import java.nio.file.Files +import java.nio.file.attribute.PosixFilePermissions + +class BundledScripts { + companion object { + @JvmStatic + fun extractScriptsToDir(dir: File, vararg scriptNames: String) { + val rwxPermissions = PosixFilePermissions.fromString("rwx------") + + for (name in scriptNames) { + val file = File(dir, name) + if (!file.parentFile.isDirectory && !file.parentFile.mkdirs()) { + throw GradleException("Could not create directory ${file.parentFile}") + } + val resourceStream: InputStream = BundledScripts::class.java.getResourceAsStream(name) + ?: throw IllegalArgumentException("Resource $name was not found") + + resourceStream.use { inputStream -> + file.outputStream().use { outputStream -> + inputStream.copyTo(outputStream) + } + } + Files.setPosixFilePermissions(file.toPath(), rwxPermissions) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/de/itemis/mps/gradle/Common.kt b/src/main/kotlin/de/itemis/mps/gradle/Common.kt index 94783cea..218f8125 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/Common.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/Common.kt @@ -1,5 +1,6 @@ package de.itemis.mps.gradle +import net.swiftzer.semver.SemVer import org.apache.log4j.Logger import org.gradle.api.GradleException import org.gradle.api.JavaVersion @@ -112,3 +113,35 @@ fun BasePluginExtensions.getMPSVersion(extensionName: String): String { // Otherwise, the version has to be provided explicitly. throw GradleException(ErrorMessages.mustSetVersionWhenNoMpsConfiguration(extensionName)) } + +class MPSVersion private constructor(val version: SemVer) { + + companion object { + + fun parse(str: String):MPSVersion { + var semVersion = SemVer.parseOrNull(str) + if (semVersion == null) { + val insertIndex = str.indexOf("-") + val newStr = if(insertIndex != -1) str.substring(0,insertIndex)+ ".0" + str.substring(insertIndex) else "$str.0" + semVersion = SemVer.parse(newStr) + } + return MPSVersion(semVersion) + } + } + + private fun appendOpt(str: String?, pre: String): String { + return if (!str.isNullOrEmpty()) "${pre}${str}" else "" + } + + private fun substringBefore(text: String, substring: String):String? { + val i: Int = text.indexOf(substring) + if (i == -1) return null + return text.substring(0, i) + } + + override fun toString(): String { + return version.toString() + } + + fun toMavenSnapshot() = "${version.major}.${version.minor}-SNAPSHOT" +} diff --git a/src/main/kotlin/de/itemis/mps/gradle/CreateDmg.kt b/src/main/kotlin/de/itemis/mps/gradle/CreateDmg.kt new file mode 100644 index 00000000..3b848180 --- /dev/null +++ b/src/main/kotlin/de/itemis/mps/gradle/CreateDmg.kt @@ -0,0 +1,106 @@ +package de.itemis.mps.gradle.de.itemis.mps.gradle + +import de.itemis.mps.gradle.BundledScripts +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.artifacts.Dependency +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.Optional +import java.io.File +import kotlin.io.path.createTempDirectory + +open class CreateDmg : DefaultTask() { + @InputFile + lateinit var rcpArtifact: File + + @InputFile + lateinit var backgroundImage: File + + @InputFile + lateinit var jdk: File + + @OutputFile + lateinit var dmgFile: File + + @Optional @Input + var signKeyChainPassword: String? = null + + @Optional @Input + var signIdentity: String? = null + + @InputFile @Optional + var signKeyChain: File? = null + + fun setSignKeyChain(file: Any) { + this.signKeyChain = project.file(file) + } + + fun setRcpArtifact(file: Any) { + this.rcpArtifact = project.file(file) + } + + fun setBackgroundImage(file: Any) { + this.backgroundImage = project.file(file) + } + + fun setJdk(file: Any) { + this.jdk = project.file(file) + } + + /** + * Sets the [jdk] property from a dependency, given as either a [Dependency] object or in dependency notation. + */ + fun setJdkDependency(jdkDependency: Any) { + val dep: Dependency = project.dependencies.create(jdkDependency) + val files = project.configurations.detachedConfiguration(dep).resolve() + if (files.size != 1) { + throw GradleException("Expected a single file for jdkDependency '$jdkDependency', got ${files.size} files") + } + this.jdk = files.first() + } + + fun setDmgFile(file: Any) { + this.dmgFile = project.file(file) + if (!dmgFile.name.endsWith(".dmg")) { + throw GradleException("Value of dmgFile must end with .dmg but was $dmgFile") + } + } + + @TaskAction + fun build() { + val scripts = arrayOf("mpssign.sh", "mpsdmg.sh", "mpsdmg.pl", + "Mac/Finder/DSStore/BuddyAllocator.pm", "Mac/Finder/DSStore.pm") + val scriptsDir = createTempDirectory().toFile() + val dmgDir = createTempDirectory().toFile() + val signingInfo = arrayOf(signKeyChainPassword, signKeyChain, signIdentity) + try { + BundledScripts.extractScriptsToDir(scriptsDir, *scripts) + project.exec { + executable = File(scriptsDir, "mpssign.sh").toString() + + if (signingInfo.all { it != null }) { + args = listOf("-r", rcpArtifact.toString(), "-o", dmgDir.toString(), "-j", jdk.toString(), "-p", signKeyChainPassword, "-k", signKeyChain.toString(), "-i", signIdentity) + } else if (signingInfo.all { it == null }) { + args = listOf("-r", rcpArtifact.toString(), "-o", dmgDir.toString(), "-j", jdk.toString()) + } else { + throw IllegalArgumentException("Not all signing parameters set. signKeyChain: ${signingInfo[1]}, signIdentity: ${signingInfo[2]} and signKeyChainPassword needs to be set.") + } + workingDir = scriptsDir + } + project.exec { + executable = File(scriptsDir, "mpsdmg.sh").toString() + args = listOf(dmgDir.toString(), dmgFile.toString(), backgroundImage.toString()) + workingDir = scriptsDir + } + } finally { + // Do not use File.deleteDir() because it follows symlinks! + // (e.g. the symlink to /Applications inside dmgDir) + project.exec { + commandLine = listOf("rm", "-rf", scriptsDir.toString(), dmgDir.toString()) + } + } + } +} diff --git a/src/main/kotlin/de/itemis/mps/gradle/GetMpsInBrowser.kt b/src/main/kotlin/de/itemis/mps/gradle/GetMpsInBrowser.kt new file mode 100644 index 00000000..e1f58d51 --- /dev/null +++ b/src/main/kotlin/de/itemis/mps/gradle/GetMpsInBrowser.kt @@ -0,0 +1,45 @@ +package de.itemis.mps.gradle + +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.TaskAction +import org.apache.tools.ant.taskdefs.condition.Os +import java.awt.Desktop +import java.net.URI + +open class GetMpsInBrowser : DefaultTask() { + + @Input + var version: String? = null + + private fun getMajorMinorPart(): String { + val mpsVersion = MPSVersion.parse(version!!) + return "${mpsVersion.version.major}.${mpsVersion.version.minor}" + } + + private fun getDownloadUrl(): URI { + val majorMinor = getMajorMinorPart() + return when { + Os.isFamily(Os.FAMILY_WINDOWS) -> URI("https://download.jetbrains.com/mps/$majorMinor/MPS-$version.exe") + Os.isFamily(Os.FAMILY_MAC) -> { + val suffix = if(Os.isArch("aarch64")) "-aarch64" else "" + URI("https://download.jetbrains.com/mps/$majorMinor/MPS-$version-macos${suffix}.dmg") + } + Os.isFamily(Os.FAMILY_UNIX) -> URI("https://download.jetbrains.com/mps/$majorMinor/MPS-$version.tar.gz") + else -> { + println("Warning: could not determine OS, downloading generic distribution") + URI("http://download.jetbrains.com/mps/$majorMinor/MPS-$version.zip") + } + } + } + + @TaskAction + fun build() { + if (Desktop.isDesktopSupported()) { + Desktop.getDesktop().browse(getDownloadUrl()) + } else { + throw GradleException("This task is not supported in headless mode") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/de/itemis/mps/gradle/Pom.kt b/src/main/kotlin/de/itemis/mps/gradle/Pom.kt new file mode 100644 index 00000000..2c90a5cd --- /dev/null +++ b/src/main/kotlin/de/itemis/mps/gradle/Pom.kt @@ -0,0 +1,44 @@ +package de.itemis.mps.gradle + +import org.gradle.api.artifacts.Configuration +import org.gradle.api.publish.maven.MavenPom + +class Pom { + + /** + * Add all top level dependencies of a configuration to a pom + * @param pom the POM node where to add the dependencies + * @param config the configuration where to get the dependencies from + */ + fun withDep(pom: MavenPom, config: Configuration) { + pom.withXml { + val dependenciesNode = asNode().appendNode("dependencies") + config.resolvedConfiguration.firstLevelModuleDependencies.forEach { + val dependencyNode = dependenciesNode.appendNode("dependency") + dependencyNode.appendNode("groupId", it.moduleGroup) + dependencyNode.appendNode("artifactId", it.moduleName) + dependencyNode.appendNode("version", it.moduleVersion) + dependencyNode.appendNode("type", it.moduleArtifacts.first().type) + } + } + } + + /** + * Add all top level dependencies of a configuration to a pom with provided scope + * @param pom the POM node where to add the dependencies + * @param config the configuration where to get the dependencies from + */ + fun withProvidedDep(pom: MavenPom, config: Configuration) { + pom.withXml { + val dependenciesNode = asNode().appendNode("dependencies") + config.resolvedConfiguration.firstLevelModuleDependencies.forEach { + val dependencyNode = dependenciesNode.appendNode("dependency") + dependencyNode.appendNode("groupId", it.moduleGroup) + dependencyNode.appendNode("artifactId", it.moduleName) + dependencyNode.appendNode("version", it.moduleVersion) + dependencyNode.appendNode("type", it.moduleArtifacts.first().type) + dependencyNode.appendNode("scope", "provided") + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/de/itemis/mps/gradle/common.gradle.kts b/src/main/kotlin/de/itemis/mps/gradle/common.gradle.kts index d296f72d..7a6f38e5 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/common.gradle.kts +++ b/src/main/kotlin/de/itemis/mps/gradle/common.gradle.kts @@ -5,6 +5,10 @@ package de.itemis.mps.gradle * ([RunAntScript], [BuildLanguages], etc.) onto the classpath. */ +plugins { + id("base") +} + val modelcheckBackend = configurations.create(BackendConfigurations.MODELCHECK_BACKEND_CONFIGURATION_NAME) val generateBackend = configurations.create(BackendConfigurations.GENERATE_BACKEND_CONFIGURATION_NAME) val executeBackend = configurations.create(BackendConfigurations.EXECUTE_BACKEND_CONFIGURATION_NAME) @@ -27,3 +31,141 @@ configurations.create(BackendConfigurations.REMIGRATE_BACKEND_CONFIGURATION_NAME add(project.dependencies.create("de.itemis.mps.build-backends:remigrate:[0,2)")) } } + +extensions.create("ci", project) + +abstract class CI(val _project: Project) { + @Suppress("unused") + fun determineCI() { + if(System.getenv("CI").toBoolean()) { + _project.extra["ciBuild"] = true + } else{ + _project.extra["ciBuild"] = _project.hasProperty("teamcity") + } + } + + @Suppress("unused") + fun isCI() = _project.extra["ciBuild"] + + @Suppress("unused") + fun buildNumber() = System.getenv("GITHUB_RUN_NUMBER").toIntOrNull() ?: System.getenv("BUILD_NUMBER").toInt() + + @Suppress("unused") + fun registerDependencyRepositories(repositories: ArrayList) { + for (repoUrl in repositories) { + _project.repositories.maven { + url = _project.uri(repoUrl) + credentials { + username = (_project.extensions.getByName("githubAuth") as GitHubAuth).user + password = (_project.extensions.getByName("githubAuth") as GitHubAuth).token + } + } + } + } +} + +extensions.create("jdk", project) + +abstract class JDK(val _project: Project) { + @Suppress("unused") + fun determine(javaVersion: JavaVersion) { + if (_project.extra.has("java${javaVersion}_home")) { + _project.extra["jdk_home"] = _project.extra.get("java${javaVersion}_home") + } else if (System.getenv("JB_JAVA${javaVersion}_HOME") != null) { + _project.extra["jdk_home"] = System.getenv("JB_JAVA${javaVersion}_HOME") + } else { + if (JavaVersion.current() != javaVersion) { + throw GradleException("This build script requires Java ${javaVersion} but you are currently using ${JavaVersion.current()}.\nWhat you can do:\n" + + " * Use project property java${javaVersion}_home to point to the Java ${javaVersion} JDK.\n" + + " * Use environment variable JB_JAVA${javaVersion}_HOME to point to the Java ${javaVersion} JDK\n" + + " * Run Gradle using Java ${javaVersion}") + } + _project.extra["jdk_home"] = System.getProperty("java.home") + } + + val jdk_home = _project.extra["jdk_home"] + // Check JDK location + if (!File(jdk_home.toString(), "lib").exists()) { + throw GradleException("Unable to locate JDK home folder. Detected folder is: ${jdk_home}") + } + _project.logger.info("Using JDK at ${jdk_home}") + } +} + +extensions.create("itemis") + +abstract class Itemis() { + @Suppress("unused") + fun mbeddrGitHub() = "https://maven.pkg.github.com/mbeddr/*" + + @Suppress("unused") + fun itemisNexus() = "https://artifacts.itemis.cloud/repository/maven-mps/" +} + +project.configurations.create("common_mps") { + description = "The MPS dependencies configuration" +} + +project.configurations.create("common_languageLibs") { + description = "The language dependencies configuration" +} + +project.configurations.create("common_antLib") { + description = "The JUnit dependencies configuration" +} + +project.extra["skipResolveMps"] = project.hasProperty("mpsHomeDir") +project.extra["mpsHomeDir"] = rootProject.file(project.findProperty("mpsHomeDir") ?: "${layout.buildDirectory.toString()}/mps") + +if (project.extra["skipResolveMps"].toString().toBoolean()) { + tasks.register("commonResolveMps") { + doLast { + logger.info("MPS resolution skipped") + logger.info("MPS home: " + (project.extra["mpsHomeDir"] as File).absolutePath) + } + } +} else { + tasks.register("commonResolveMps") { + if(configurations.findByName("mps")!= null) { + dependsOn(configurations.getByName("mps")) + from(configurations.getByName("mps").resolve().map { zipTree(it) }) + } + if(configurations.findByName("common_mps")!= null) { + dependsOn(configurations.getByName("common_mps")) + from(configurations.getByName("common_mps").resolve().map { zipTree(it) }) + } + + project.extra["mpsHomeDir"]?.let { into(it) } + } +} + +tasks.register("commonCleanMps") { + delete(fileTree(mapOf( + "dir" to projectDir, + "include" to listOf("**/classes_gen/**", "**/source_gen/**", "**/source_gen.caches/**", "tmp/**") + ))) +} + +tasks.named("clean") { + dependsOn("commonCleanMPS") +} + +extensions.create("githubAuth", project) + +abstract class GitHubAuth(_project: Project) { + val user:String? = (_project.findProperty("github_username") ?: System.getenv("GITHUB_ACTOR"))?.toString() + val token:String? = (_project.findProperty("github_token") ?: System.getenv("GITHUB_TOKEN"))?.toString() +} + +extensions.create("directories",project) + +abstract class Directories(val _project: Project) { + @Suppress("unused") + fun artifactsDir() :File = _project.file("${_project.layout.projectDirectory}/artifacts") + + @Suppress("unused") + fun scriptFile(name:String):File = _project.file("${_project.layout.projectDirectory}/scripts/$name") + + @Suppress("unused") + fun jnLibraryPath():File = File(_project.extra["mpsHomeDir"].toString(), "lib/jna/${System.getProperty("os.arch")}") +} \ No newline at end of file diff --git a/src/main/kotlin/de/itemis/mps/gradle/downloadJBR/Plugin.kt b/src/main/kotlin/de/itemis/mps/gradle/downloadJBR/Plugin.kt index 512eb0dc..cb49e01a 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/downloadJBR/Plugin.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/downloadJBR/Plugin.kt @@ -6,14 +6,17 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.file.DirectoryProperty import org.gradle.api.model.ObjectFactory +import org.gradle.kotlin.dsl.extra import java.io.File import javax.inject.Inject open class DownloadJbrConfiguration @Inject constructor(objects: ObjectFactory) { lateinit var jbrVersion: String + var defaultJavaExecutable = false var distributionType : String? = null internal val downloadDirProperty: DirectoryProperty = objects.directoryProperty() + @Suppress("unused") var downloadDir: File? get() = downloadDirProperty.get().asFile set(value) { @@ -21,6 +24,7 @@ open class DownloadJbrConfiguration @Inject constructor(objects: ObjectFactory) } } +@Suppress("unused") open class DownloadJbrProjectPlugin : Plugin { override fun apply(project: Project) { project.run { @@ -84,6 +88,9 @@ open class DownloadJbrProjectPlugin : Plugin { else "jbr" )) javaExecutableProperty.set(jbrDirProperty.file(if (Os.isFamily(Os.FAMILY_WINDOWS)) "bin/java.exe" else "bin/java")) + if(extension.defaultJavaExecutable) { + project.extra["itemis.mps.gradle.ant.defaultJavaExecutable"] = javaExecutableProperty.asFile + } } } } diff --git a/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt b/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt index fa76f9ce..b277365c 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt @@ -1,8 +1,7 @@ package de.itemis.mps.gradle.runmigrations -import de.itemis.mps.gradle.BasePluginExtensions +import de.itemis.mps.gradle.* import de.itemis.mps.gradle.ErrorMessages -import de.itemis.mps.gradle.getMPSVersion import de.itemis.mps.gradle.runAnt import groovy.xml.MarkupBuilder import net.swiftzer.semver.SemVer @@ -56,17 +55,17 @@ open class RunMigrationsMpsProjectPlugin : Plugin { } val mpsVersion = extension.getMPSVersion(extensionName) - val parsedMPSVersion = SemVer.parse(mpsVersion) + val parsedMPSVersion:MPSVersion = MPSVersion.parse(mpsVersion) - if (extension.force != null && parsedMPSVersion < MIN_VERSION_FOR_FORCE) { + if (extension.force != null && parsedMPSVersion.version < MIN_VERSION_FOR_FORCE) { throw GradleException("The force migration flag is only supported for MPS version $MIN_VERSION_FOR_FORCE and higher.") } - if (extension.haltOnPrecheckFailure != null && parsedMPSVersion < MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE) { + if (extension.haltOnPrecheckFailure != null && parsedMPSVersion.version < MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE) { throw GradleException("The 'do not halt on pre-check failure' option is only supported for MPS version $MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE and higher.") } - if (extension.haltOnDependencyError != null && parsedMPSVersion < MIN_VERSION_FOR_HALT_ON_DEPENDENCY_ERROR) { + if (extension.haltOnDependencyError != null && parsedMPSVersion.version < MIN_VERSION_FOR_HALT_ON_DEPENDENCY_ERROR) { throw GradleException("The 'do not halt on dependency error' option is only supported for MPS version $MIN_VERSION_FOR_HALT_ON_DEPENDENCY_ERROR and higher.") }