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

Hotfix/publish plugin jar #87

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
//noinspection GroovyUnusedAssignment
@SuppressWarnings(['UnusedVariable', 'NoDef', 'VariableTypeRequired'])
@Library('[email protected].0') dummy
@Library('[email protected].1') dummy

defaultJvmPipeline(
publicReleases: Boolean.FALSE,
Expand Down
16 changes: 4 additions & 12 deletions src/main/groovy/org/fidata/gradle/GradlePluginPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.testing.Test
import org.gradle.plugin.devel.GradlePluginDevelopmentExtension
import org.gradle.plugin.devel.tasks.ValidateTaskProperties
Expand Down Expand Up @@ -179,16 +178,6 @@ final class GradlePluginPlugin extends AbstractProjectPlugin implements Property

private void configureArtifacts() {
project.plugins.findPlugin(JvmBasePlugin)?.mainPublicationName?.set 'pluginMaven' /* Hardcoded in MavenPluginPublishPlugin */

project.afterEvaluate {
if (project.convention.getPlugin(ProjectConvention).publicReleases) {
project.plugins.findPlugin(JvmBasePlugin)?.with {
sourcesJar.set project.tasks.withType(Jar).named(/*PublishPlugin.SOURCES_JAR_TASK_NAME*/ 'publishPluginJar')
javadocJar.set project.tasks.withType(Jar).named(/*PublishPlugin.JAVA_DOCS_TASK_NAME*/ 'publishPluginJavaDocsJar')
}
project.plugins.findPlugin(GroovyBasePlugin)?.groovydocJar?.set project.tasks.withType(Jar).named(/*PublishPlugin.GROOVY_DOCS_TASK_NAME*/ 'publishPluginGroovyDocsJar')
}
}
}

private void configurePublicReleases() {
Expand All @@ -211,6 +200,7 @@ final class GradlePluginPlugin extends AbstractProjectPlugin implements Property
extension.website = projectConvention.websiteUrl.get()
extension.vcsUrl = rootProjectConvention.vcsUrl.get()
}

project.tasks.named(/* WORKAROUND: PublishPlugin.BASE_TASK_NAME has private scope <grv87 2018-06-23> */ 'publishPlugins').configure { Task publishPlugins ->
publishPlugins.onlyIf { rootProjectConvention.isRelease.get() }
}
Expand All @@ -222,7 +212,9 @@ final class GradlePluginPlugin extends AbstractProjectPlugin implements Property

private void configureReleases() {
GString repository = "plugins-${ project.rootProject.convention.getPlugin(RootProjectConvention).isRelease.get() ? 'release' : 'snapshot' }"
project.convention.getPlugin(ArtifactoryPluginConvention).clientConfig.publisher.repoKey = "$repository-local"
if (project.name != 'buildSrc') {
project.convention.getPlugin(ArtifactoryPluginConvention).clientConfig.publisher.repoKey = "$repository-local"
}
project.repositories.maven { MavenArtifactRepository mavenArtifactRepository ->
mavenArtifactRepository.with {
/*
Expand Down
27 changes: 6 additions & 21 deletions src/main/groovy/org/fidata/gradle/GroovyBasePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.fidata.gradle.internal.AbstractProjectPlugin
import org.fidata.gradle.utils.PluginDependeesUtils
import org.gradle.api.NamedDomainObjectProvider
import org.gradle.api.artifacts.Configuration
import org.gradle.api.provider.Property
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.compile.GroovyCompile
Expand Down Expand Up @@ -100,34 +99,20 @@ final class GroovyBasePlugin extends AbstractProjectPlugin {
*/
public static final String GROOVYDOC_JAR_ARTIFACT_CLASSIFIER = 'groovydoc'

private TaskProvider<Jar> defaultGroovydocJarProvider
private TaskProvider<Jar> groovydocJarProvider

@PackageScope
TaskProvider<Jar> getDefaultGroovydocJarProvider() {
this.@defaultGroovydocJarProvider
}

@PackageScope
private Property<Jar> groovydocJar

@PackageScope
Property<Jar> getGroovydocJar() {
this.@groovydocJar
TaskProvider<Jar> getGroovydocJarProvider() {
this.@groovydocJarProvider
}

private void configureArtifacts() {
this.@defaultGroovydocJarProvider = project.tasks.register(GROOVYDOC_JAR_TASK_NAME, Jar) { Jar defaultGroovydocJar ->
defaultGroovydocJar.archiveClassifier.set GROOVYDOC_JAR_ARTIFACT_CLASSIFIER
groovydocJarProvider = project.tasks.register(GROOVYDOC_JAR_TASK_NAME, Jar) { Jar groovydocJar ->
groovydocJar.archiveClassifier.set GROOVYDOC_JAR_ARTIFACT_CLASSIFIER
}
this.@groovydocJar = project.objects.property(Jar).convention(defaultGroovydocJarProvider)

project.afterEvaluate {
defaultGroovydocJarProvider.configure { Jar defaultGroovydocJar ->
defaultGroovydocJar.enabled = groovydocJar.get() == defaultGroovydocJar
null
}

project.plugins.getPlugin(JvmBasePlugin).mainPublication.artifact groovydocJar.get()
project.plugins.getPlugin(JvmBasePlugin).mainPublication.artifact groovydocJarProvider.get()
}
}
}
7 changes: 5 additions & 2 deletions src/main/groovy/org/fidata/gradle/GroovyProjectPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ final class GroovyProjectPlugin extends AbstractProjectPlugin {
}

private void configureArtifacts() {
project.plugins.getPlugin(GroovyBasePlugin).defaultGroovydocJarProvider.configure { Jar defaultGroovydocJar ->
defaultGroovydocJar.from project.tasks.withType(Groovydoc).named(GROOVYDOC_TASK_NAME)
project.plugins.getPlugin(JvmBasePlugin).javadocJarProvider.configure { Jar javadocJar ->
javadocJar.enabled = false
}
project.plugins.getPlugin(GroovyBasePlugin).groovydocJarProvider.configure { Jar groovydocJar ->
groovydocJar.from project.tasks.withType(Groovydoc).named(GROOVYDOC_TASK_NAME)
}
}
}
4 changes: 2 additions & 2 deletions src/main/groovy/org/fidata/gradle/JavaProjectPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ final class JavaProjectPlugin extends AbstractProjectPlugin {
}

private void configureArtifacts() {
project.plugins.getPlugin(JvmBasePlugin).defaultJavadocJarProvider.configure { Jar defaultJavadocJar ->
defaultJavadocJar.from project.tasks.withType(Javadoc).named(JAVADOC_TASK_NAME)
project.plugins.getPlugin(JvmBasePlugin).javadocJarProvider.configure { Jar javadocJar ->
javadocJar.from project.tasks.withType(Javadoc).named(JAVADOC_TASK_NAME)
}
}
}
62 changes: 22 additions & 40 deletions src/main/groovy/org/fidata/gradle/JvmBasePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -493,65 +493,45 @@ final class JvmBasePlugin extends AbstractProjectPlugin implements PropertyChang
mainPublication
}

private TaskProvider<Jar> defaultSourcesJarProvider
private TaskProvider<Jar> sourcesJarProvider

@PackageScope
TaskProvider<Jar> getDefaultSourcesJarProvider() {
this.@defaultSourcesJarProvider
TaskProvider<Jar> getSourcesJarProvider() {
this.@sourcesJarProvider
}

private Property<Jar> sourcesJar
private TaskProvider<Jar> javadocJarProvider

@PackageScope
Property<Jar> getSourcesJar() {
this.@sourcesJar
}

private TaskProvider<Jar> defaultJavadocJarProvider

@PackageScope
TaskProvider<Jar> getDefaultJavadocJarProvider() {
this.@defaultJavadocJarProvider
}

@PackageScope
private Property<Jar> javadocJar

@PackageScope
Property<Jar> getJavadocJar() {
this.@javadocJar
TaskProvider<Jar> getJavadocJarProvider() {
this.@javadocJarProvider
}

private void configureArtifacts() {
this.@mainPublicationName = project.objects.property(String).convention(MAVEN_JAVA_PUBLICATION_NAME)

this.@defaultSourcesJarProvider = project.tasks.register(SOURCES_JAR_TASK_NAME, Jar) { Jar defaultSourceJar ->
defaultSourceJar.with {
this.@sourcesJarProvider = project.tasks.register(SOURCES_JAR_TASK_NAME, Jar) { Jar sourcesJar ->
sourcesJar.with {
from project.convention.getPlugin(JavaPluginConvention).sourceSets.getByName(MAIN_SOURCE_SET_NAME).allSource
// dependsOn
archiveClassifier.set SOURCES_JAR_ARTIFACT_CLASSIFIER
}
}
this.@sourcesJar = project.objects.property(Jar).convention(defaultSourcesJarProvider)

this.@defaultJavadocJarProvider = project.tasks.register(JAVADOC_JAR_TASK_NAME, Jar) { Jar defaultJavadocJar ->
defaultJavadocJar.archiveClassifier.set JAVADOC_JAR_ARTIFACT_CLASSIFIER
this.@javadocJarProvider = project.tasks.register(JAVADOC_JAR_TASK_NAME, Jar) { Jar javadocJar ->
javadocJar.archiveClassifier.set JAVADOC_JAR_ARTIFACT_CLASSIFIER
}
this.@javadocJar = project.objects.property(Jar).convention(defaultJavadocJarProvider)

project.afterEvaluate {
defaultSourcesJarProvider.configure { Jar defaultSourcesJar ->
defaultSourcesJar.enabled = sourcesJar.get() == defaultSourcesJar
null
}
defaultJavadocJarProvider.configure { Jar defaultJavadocJar ->
defaultJavadocJar.enabled = javadocJar.get() == defaultJavadocJar
null
}

mainPublication.with {
artifact sourcesJar.get()
artifact javadocJar.get()
Jar sourcesJar = sourcesJarProvider.get()
if (sourcesJar.enabled) {
artifact sourcesJar
}
Jar javadocJar = javadocJarProvider.get()
if (javadocJar.enabled) {
artifact javadocJar
}
}
}

Expand Down Expand Up @@ -668,7 +648,7 @@ final class JvmBasePlugin extends AbstractProjectPlugin implements PropertyChang
}

private void configureGithubReleases() {
GitRepo repo = project.extensions.getByType(SemanticReleasePluginExtension).repo
GitRepo repo = project.rootProject.extensions.getByType(SemanticReleasePluginExtension).repo
project.afterEvaluate {
/**
* CRED:
Expand Down Expand Up @@ -715,7 +695,9 @@ final class JvmBasePlugin extends AbstractProjectPlugin implements PropertyChang
}

private void configureReleases() {
configureArtifactory()
if (project.name != 'buildSrc') {
configureArtifactory()
}

configurePublicReleases()
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/groovy/org/fidata/gradle/ProjectPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ final class ProjectPlugin extends AbstractProjectPlugin {
createGenerateChangelogTasks()
}

configureArtifactory()
if (project.name != 'buildSrc') {
configureArtifactory()
}
}
}