Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish outdated configs #831

Merged
merged 5 commits into from
Mar 20, 2023
Merged
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
34 changes: 3 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id 'groovy'
id 'project-report'
id 'idea'
id 'java-gradle-plugin'
// id 'signing'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I will re-add signing as plugin-publish supports it natively. I had turned this off when troubleshooting errors with publishing the 8.1.0 plugin.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put it back, believe you just set signing.required = false will disable the sign tasks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id 'signing'
id 'com.gradle.plugin-publish' version '1.1.0'
id 'org.ajoberstar.git-publish' version '4.1.1'
id 'com.github.node-gradle.node' version '3.5.1'
}

// Remove the gradleApi so it isn't merged into the jar file.
configurations.named(JavaPlugin.API_CONFIGURATION_NAME) {
dependencies.remove(project.dependencies.gradleApi())
}
Comment on lines -14 to -17
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compileOnly should be enough

./gradlew assemble

diffuse diff --jar shadow-8.1.0-SNAPSHOT-before.jar shadow-8.1.0-SNAPSHOT-after.jar

OLD: shadow-8.1.0-SNAPSHOT-before.jar
NEW: shadow-8.1.0-SNAPSHOT-after.jar

 JAR   │ old       │ new       │ diff 
───────┼───────────┼───────────┼──────
 class │ 700.9 KiB │ 700.9 KiB │  0 B 
 other │  10.6 KiB │  10.6 KiB │  0 B 
───────┼───────────┼───────────┼──────
 total │ 711.5 KiB │ 711.5 KiB │  0 B 


 CLASSES │ old  │ new  │ diff      
─────────┼──────┼──────┼───────────
 classes │  146 │  146 │ 0 (+0 -0) 
 methods │ 1813 │ 1813 │ 0 (+0 -0) 
  fields │  746 │  746 │ 0 (+0 -0) 

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to have broken shadowJar itself in this project. I think you're only comparing the output of the jar command above. However, the shadowJar tasks has been running for 18m on my machine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so applying the Gradle Plugin plugin adds the gradleApi() to the api configuration...https://github.com/gradle/gradle/blob/master/subprojects/plugin-development/src/main/java/org/gradle/plugin/devel/plugins/JavaGradlePluginPlugin.java#L162

And this is what this block was doing before.
So the compileOnly change works, but this block needs to be kept to remove this behavior (as there is no way to exclude the dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've read-ed this line in 8.1.1. I'm not sure if that affects the configuration caching in an way.


apply plugin: ShadowPlugin

apply from: file('gradle/docs.gradle')
Expand All @@ -41,18 +37,10 @@ test {
systemProperty 'java.io.tmpdir', buildDir.absolutePath
}

// jar {
// from rootProject.file('LICENSE')
// from rootProject.file('NOTICE')
// }

// jar.enabled = false

shadowJar {
tasks.named('shadowJar', ShadowJar) {
from rootProject.file('LICENSE')
from rootProject.file('NOTICE')
enableRelocation true
// archiveClassifier = ''
}

idea {
Expand All @@ -72,19 +60,3 @@ tasks.register('downloadDependencies', Exec) {
dependsOn configurations.testRuntimeClasspath
commandLine 'echo', 'Downloaded all dependencies'
}

// tasks.named('build') { dependsOn tasks.named('shadowJar') }

// tasks.withType(JavaCompile).configureEach {
// // This will be the default in Gradle 5.0
// if (!options.compilerArgs.contains("-processor")) {
// options.compilerArgs << '-proc:none'
// }
// }

// tasks.withType(GroovyCompile).configureEach {
// // This will be the default in Gradle 5.0
// if (!options.compilerArgs.contains("-processor")) {
// options.compilerArgs << '-proc:none'
// }
// }
18 changes: 3 additions & 15 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.codehaus.groovy.control.CompilerConfiguration

apply plugin: 'groovy'
plugins {
id 'groovy'
}

repositories {
gradlePluginPortal()
Expand Down Expand Up @@ -52,17 +54,3 @@ sourceSets {
resources.srcDirs = ['../src/main/resources']
}
}

tasks.withType(JavaCompile).configureEach {
// This will be the default in Gradle 5.0
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
}

tasks.withType(GroovyCompile).configureEach {
// This will be the default in Gradle 5.0
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
}
Comment on lines -56 to -68
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we can remove these from buildSrc too?

5 changes: 2 additions & 3 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
dependencies {

shadow localGroovy()
shadow gradleApi()
compileOnly localGroovy()
compileOnly gradleApi()
shadow 'org.codehaus.groovy:groovy-backports-compat23:3.0.8'

implementation 'org.jdom:jdom2:2.0.6.1'
Expand Down
12 changes: 3 additions & 9 deletions gradle/docs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ tasks.withType(Javadoc).configureEach {
}
}

tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier.set('javadoc')
from 'build/docs/javadoc'
}

tasks.register('sourcesJar', Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
java {
withJavadocJar()
withSourcesJar()
}

tasks.named('groovydoc') {
Expand Down
6 changes: 3 additions & 3 deletions gradle/ghPages.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'org.ajoberstar.git-publish'

if (project.hasProperty('githubToken')) {
System.setProperty('org.ajoberstar.grgit.auth.username', project.githubToken)
System.setProperty('org.ajoberstar.grgit.auth.username', project.property('githubToken') as String)
}

gitPublish {
Expand All @@ -23,5 +23,5 @@ gitPublish {
}
}

tasks.named('gitPublishCopy') { dependsOn yarn_build }
tasks.named('gitPublishCopy') { dependsOn groovydoc }
tasks.named('gitPublishCopy') { dependsOn tasks.named('yarn_build') }
tasks.named('gitPublishCopy') { dependsOn tasks.named('groovydoc') }
37 changes: 16 additions & 21 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ if (System.env.CIRCLE_TAG && System.env.CIRCLE_TAG =~ /^\d\.\d\.\d$/) {
}
}

// tasks.configureEach {
// if (name == "publishPluginJar" || name == "generateMetadataFileForPluginMavenPublication") {
// dependsOn(tasks.named("shadowJar"))
// }
// }

gradlePlugin {
website = 'https://github.com/johnrengelman/shadow'
vcsUrl = 'https://github.com/johnrengelman/shadow'
Expand All @@ -41,21 +35,22 @@ tasks.named('publishPlugins') {
notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/21283")
}

// signing {
// if (System.env.CI == 'true') {
// def encodedSigningKey = findProperty("signingKey")
// def signingKey = encodedSigningKey ? new String(encodedSigningKey.decodeBase64()) : null
// def signingPassword = findProperty("signingPassword")
// useInMemoryPgpKeys(signingKey, signingPassword)
// }
// required = gradle.taskGraph.hasTask("artifactoryPublish")
// sign(publishing.publications)
// }

// tasks.withType(Sign).configureEach {
// notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/13470")
// }
signing {
if (System.env.CI == 'true') {
def encodedSigningKey = findProperty("signingKey")
def signingKey = encodedSigningKey ? new String(encodedSigningKey.decodeBase64()) : null
def signingPassword = findProperty("signingPassword") as String
useInMemoryPgpKeys(signingKey, signingPassword)
}
// See https://github.com/johnrengelman/shadow/pull/831#discussion_r1119012328
required = false && gradle.taskGraph.hasTask("artifactoryPublish")
Comment on lines +45 to +46
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled for now.

sign(publishing.publications)
}

tasks.withType(Sign).configureEach {
notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/13470")
}

tasks.register('release') {
dependsOn 'assemble', 'publishPlugins', 'gitPublishPush'
dependsOn tasks.named('assemble'), tasks.named('publishPlugins'), tasks.named('gitPublishPush')
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.gradle.api.artifacts.SelfResolvingDependency
import org.gradle.api.file.CopySpec
import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.util.GradleVersion

class ShadowExtension {

Expand All @@ -19,12 +18,7 @@ class ShadowExtension {
}

void component(MavenPublication publication) {

if (GradleVersion.current() >= GradleVersion.version("6.6")) {
publication.artifact(project.tasks.named("shadowJar"))
} else {
publication.artifact(project.tasks.shadowJar)
}
publication.artifact(project.tasks.named("shadowJar"))

publication.pom { MavenPom pom ->
pom.withXml { xml ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.gradle.api.attributes.LibraryElements
import org.gradle.api.attributes.Usage
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.configuration.project.ProjectConfigurationActionContainer
import org.gradle.util.GradleVersion

import javax.inject.Inject

Expand Down Expand Up @@ -59,15 +58,7 @@ class ShadowJavaPlugin implements Plugin<Project> {
project.tasks.register(SHADOW_JAR_TASK_NAME, ShadowJar) { shadow ->
shadow.group = SHADOW_GROUP
shadow.description = 'Create a combined JAR of project and runtime dependencies'
if (GradleVersion.current() >= GradleVersion.version("5.1")) {
shadow.archiveClassifier.set("all")
} else {
shadow.conventionMapping.with {
map('classifier') {
'all'
}
}
}
shadow.archiveClassifier.set("all")
shadow.manifest.inheritFrom(project, project.tasks.jar.manifest)
def libsProvider = project.provider { -> [project.tasks.jar.manifest.attributes.get('Class-Path')] }
def files = project.objects.fileCollection().from { ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.gradle.api.internal.file.copy.CopySpecInternal
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.bundling.ZipEntryCompression
import org.gradle.api.tasks.util.PatternSet
import org.gradle.util.GradleVersion

class GradleVersionUtil {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.github.jengelman.gradle.plugins.shadow.tasks

import com.github.jengelman.gradle.plugins.shadow.ShadowStats
import com.github.jengelman.gradle.plugins.shadow.impl.RelocatorRemapper
import com.github.jengelman.gradle.plugins.shadow.internal.GradleVersionUtil
import com.github.jengelman.gradle.plugins.shadow.internal.UnusedTracker
import com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor
import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
Expand Down