diff --git a/.gitignore b/.gitignore index ac819be6d..3fff7aae9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # output dir -target build /build-dir /build-cache /deploy-with-env.sh +/release-with-env.sh /.gradle /build-logic/.gradle /relocated @@ -33,5 +33,3 @@ local.properties !.idea/codeStyles !.idea/copyright !.idea/checkstyle-idea.xml - -dependency-reduced-pom.xml \ No newline at end of file diff --git a/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtensionImpl.java b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtensionImpl.java index 0c431892d..73cd55c36 100644 --- a/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtensionImpl.java +++ b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtensionImpl.java @@ -67,6 +67,7 @@ class DependencyRelocationExtensionImpl implements DependencyRelocationExtension project.getPlugins().apply(VersionCatalogPlugin.class); project.getPlugins().apply(JavaLibraryPlugin.class); project.getPlugins().apply(PublishTeaVMPlugin.class); + project.setDescription("Relocated " + dependency.alias + " artifact to avoid JAR hell"); var synthesizedProjects = new HashMap(); for (var dep : depsByProjectPath.values()) { diff --git a/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMPlugin.java b/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMPlugin.java index 48335198a..d86a2fce9 100644 --- a/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMPlugin.java +++ b/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMPlugin.java @@ -24,6 +24,8 @@ import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; import org.gradle.api.publish.plugins.PublishingPlugin; import org.gradle.api.tasks.javadoc.Javadoc; import org.gradle.external.javadoc.CoreJavadocOptions; +import org.gradle.plugins.signing.SigningExtension; +import org.gradle.plugins.signing.SigningPlugin; public abstract class PublishTeaVMPlugin implements Plugin { private static final String EXTENSION_NAME = "teavmPublish"; @@ -32,6 +34,7 @@ public abstract class PublishTeaVMPlugin implements Plugin { public void apply(Project target) { target.getPlugins().apply(PublishingPlugin.class); target.getPlugins().apply(MavenPublishPlugin.class); + target.getPlugins().apply(SigningPlugin.class); var extension = new ExtensionImpl(); target.getExtensions().add(PublishTeaVMExtension.class, EXTENSION_NAME, extension); @@ -42,6 +45,12 @@ public abstract class PublishTeaVMPlugin implements Plugin { customizePublication(target, publication, extension); }); }); + var publish = Boolean.parseBoolean(target.getProviders().gradleProperty("teavm.mavenCentral.publish") + .getOrElse("false")); + if (publish) { + var signing = target.getExtensions().getByType(SigningExtension.class); + publishing.getPublications().configureEach(signing::sign); + } publishing.repositories(repositories -> { var url = target.getProviders().gradleProperty("teavm.publish.url"); if (url.isPresent()) { @@ -54,7 +63,16 @@ public abstract class PublishTeaVMPlugin implements Plugin { "teavm.publish.password").get()); }); } - repositories.mavenCentral(); + if (publish) { + repositories.maven(repository -> { + repository.setName("OSSRH"); + repository.setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2"); + repository.getCredentials().setUsername(target.getProviders().gradleProperty( + "ossrhUsername").get()); + repository.getCredentials().setPassword(target.getProviders().gradleProperty( + "ossrhPassword").get()); + }); + } }); })); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ac085a8cd..29d43633e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -71,4 +71,4 @@ version.ref = "shadow" [plugins] shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" } -intellij = { id = "org.jetbrains.intellij", version = "1.10.0" } \ No newline at end of file +intellij = { id = "org.jetbrains.intellij", version = "1.13.1" } \ No newline at end of file diff --git a/release.sh b/release.sh new file mode 100755 index 000000000..27f5e96dd --- /dev/null +++ b/release.sh @@ -0,0 +1,49 @@ +# +# Copyright 2023 Alexey Andreev. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +mkdir -p build-dir + +git fetch +git archive master | tar -x -C build-dir || { echo 'Git archive failed' ; exit 1; } + +TEAVM_RELEASE_VERSION=$1 + +function release_teavm { + echo "Building version $TEAVM_RELEASE_VERSION" + + GRADLE="./gradlew" + GRADLE+=" --no-daemon --no-configuration-cache --stacktrace" + GRADLE+=" -Pteavm.mavenCentral.publish=true" + GRADLE+=" -Pteavm.project.version=$TEAVM_RELEASE_VERSION" + GRADLE+=" -Psigning.keyId=$TEAVM_GPG_KEY_ID" + GRADLE+=" -Psigning.password=$TEAVM_GPG_PASSWORD" + GRADLE+=" -Psigning.secretKeyRingFile=$HOME/.gnupg/secring.gpg" + GRADLE+=" -PossrhUsername=$TEAVM_SONATYPE_LOGIN" + GRADLE+=" -PossrhPassword=$TEAVM_SONATYPE_PASSWORD" + GRADLE+=" -Pteavm.idea.publishToken='$TEAVM_INTELLIJ_TOKEN'" + + $GRADLE build -x test || { echo 'Build failed' ; return 1; } + $GRADLE --max-workers 1 publish publishPlugin || { echo 'Release failed' ; return 1; } + + return 0 +} + +pushd build-dir +release_teavm +EXIT_CODE=$? +popd +rm -rf build-dir +exit $EXIT_CODE diff --git a/settings.gradle.kts b/settings.gradle.kts index 787c0a4a1..0a6f228ef 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -83,13 +83,15 @@ gradle.afterProject { extensions.findByType()?.apply { publications.all { if (this is MavenPublication) { - pom { setupPom() } + pom { setupPom(this@afterProject) } } } } } -fun MavenPom.setupPom() { +fun MavenPom.setupPom(project: Project) { + name.set(project.description) + description.set(project.description) licenses { license { name.set("The Apache Software License, Version 2.0") diff --git a/tools/c-incremental/build.gradle.kts b/tools/c-incremental/build.gradle.kts index 167ada1e4..e14504d05 100644 --- a/tools/c-incremental/build.gradle.kts +++ b/tools/c-incremental/build.gradle.kts @@ -16,7 +16,6 @@ plugins { `java-library` - `teavm-publish` } description = "Incremental generator of C code" @@ -25,7 +24,3 @@ dependencies { implementation(project(":core")) implementation(project(":tools:core")) } - -teavmPublish { - artifactId = "teavm-c-inremental" -} \ No newline at end of file diff --git a/tools/gradle/build.gradle.kts b/tools/gradle/build.gradle.kts index bc2de720e..7c4998f73 100644 --- a/tools/gradle/build.gradle.kts +++ b/tools/gradle/build.gradle.kts @@ -20,6 +20,8 @@ plugins { `teavm-publish` } +description = "TeaVM Gradle plugin" + dependencies { implementation(project(":core")) implementation(project(":tools:core")) @@ -30,10 +32,14 @@ gradlePlugin { create("TeaVMPlugin") { id = "org.teavm" implementationClass = "org.teavm.gradle.TeaVMPlugin" + displayName = "TeaVM application plugin" + description = "Installs TeaVM compilation tasks, configurations and source sets" } create("TeaVMLibraryPlugin") { id = "org.teavm.library" implementationClass = "org.teavm.gradle.TeaVMLibraryPlugin" + displayName = "TeaVM library plugin" + description = "Installs TeaVM DSL for consuming TeaVM libraries and running tests in a browser" } } } @@ -104,8 +110,5 @@ publishing { artifactId = "teavm-gradle-plugin" } } - repositories { - mavenLocal() - } } diff --git a/tools/idea/build.gradle.kts b/tools/idea/build.gradle.kts index 6a31b4694..7aaf0b0dd 100644 --- a/tools/idea/build.gradle.kts +++ b/tools/idea/build.gradle.kts @@ -29,7 +29,6 @@ intellij { "org.jetbrains.kotlin" )) - } dependencies { @@ -47,4 +46,8 @@ tasks { buildSearchableOptions { enabled = false } + + publishPlugin { + token.set(providers.gradleProperty("teavm.idea.publishToken")) + } } diff --git a/tools/idea/src/main/resources/META-INF/plugin.xml b/tools/idea/src/main/resources/META-INF/plugin.xml index 42ccd03f9..e282a05ed 100644 --- a/tools/idea/src/main/resources/META-INF/plugin.xml +++ b/tools/idea/src/main/resources/META-INF/plugin.xml @@ -1,6 +1,6 @@ org.teavm.idea - TeaVM IDEA Integration + TeaVM Integration ${project.version} TeaVM community