Skip to content

Commit

Permalink
Drop feature: Mojo sourceset (#275)
Browse files Browse the repository at this point in the history
Resolves #210
  • Loading branch information
britter authored Dec 23, 2024
1 parent 740783c commit 1f31e89
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 36 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Maven Plugin Development Gradle plugin - Changelog

## Version 1.0

This release marks the move of this plugin to the [GradleX project](https://github.com/gradlex-org).
Consequently this is a breaking release with features being dropped, plugin ID and code coordinate changes, and the implementation language changing from Kotlin to Java.
The minimal required Gradle version has been increased to 7.0.
Lower versions of Gradle might be supported but are not tested.

* [Fixed] [#210](https://github.com/britter/maven-plugin-development/issues/210) Drop feature: Mojo source set. It's not longer possibel to define a dedicated source set for defining the mojo. Use a dedicated project instead.

## Version 0.4.3

* [Fixed] [#166](https://github.com/britter/maven-plugin-development/issues/166) Fix deprecation warnings. Thanks to https://github.com/Goooler[Zongle Wang].
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This plugin aims to fill the tiny gap for people who need to create an [Apache Maven](https://maven.apache.org) plugin from a Gradle build.
To do this the plugin wraps around the [Maven Plugin Tools API](https://maven.apache.org/plugin-tools/) and feeds it with the right inputs from the Gradle build.

Compatible with Gradle 5.5.1 or later.
Compatible with Gradle 7.x or later.

## Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ interface MavenPluginDevelopmentExtension {
const val NAME = "mavenPlugin"
}

val pluginSourceSet: Property<SourceSet>

val groupId: Property<String>

val artifactId: Property<String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ class MavenPluginDevelopmentPlugin : Plugin<Project> {
runtimeDependencies.set(extension.dependencies)
}

val main = project.extensions.getByType<SourceSetContainer>()["main"]
val generateTask = tasks.register<GenerateMavenPluginDescriptorTask>("generateMavenPluginDescriptor") {
group = TASK_GROUP_NAME
description = "Generates the Maven plugin descriptor file"

classesDirs.set(extension.pluginSourceSet.map { it.output.classesDirs })
sourcesDirs.set(extension.pluginSourceSet.map { it.java.sourceDirectories })
javaClassesDir.set(extension.pluginSourceSet.flatMap { it.java.classesDirectory })
classesDirs.set(main.output.classesDirs)
sourcesDirs.set(main.java.sourceDirectories)
javaClassesDir.set(main.java.classesDirectory)
upstreamProjects.convention(provider {
val compileClasspath = configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)
compileClasspath.incoming.dependencies
Expand Down Expand Up @@ -112,14 +113,13 @@ class MavenPluginDevelopmentPlugin : Plugin<Project> {
additionalMojos.set(extension.mojos)
runtimeDependencies.set(extension.dependencies)

dependsOn(extension.pluginSourceSet.map { it.output }, generateHelpMojoTask)
dependsOn(main.output, generateHelpMojoTask)
}

project.afterEvaluate {
val sourceSet = extension.pluginSourceSet.get()
val jarTask: Jar? = tasks.findByName(sourceSet.jarTaskName) as Jar?
val jarTask: Jar? = tasks.findByName(main.jarTaskName) as Jar?
jarTask?.from(generateTask)
sourceSet.java.srcDir(generateHelpMojoTask.map { it.outputDirectory })
main.java.srcDir(generateHelpMojoTask.map { it.outputDirectory })
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import javax.inject.Inject

open class DefaultMavenPluginDevelopmentExtension @Inject constructor(project: Project) : MavenPluginDevelopmentExtension {

override val pluginSourceSet: Property<SourceSet> = project.objects.property<SourceSet>()
.convention(project.provider { project.extensions.getByType<SourceSetContainer>()["main"] })

override val groupId: Property<String> = project.objects.property<String>()
.convention(project.provider { project.group.toString() })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ class GradleCrossVersionTest extends AbstractPluginFuncTest {
.build()

where:
gradleVersion << ["5.5.1", "5.6.4", "6.0.1", "6.9.4", "7.0.2", "7.6.4", "8.0.2"]
gradleVersion << ["7.0.2", "7.6.4", "8.0.2"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,6 @@ class PluginDescriptorGenerationFuncTest extends AbstractPluginFuncTest {
helpDescriptor.hasGoal("touch")
}

def "generates a plugin descriptor and help descriptor for a different source set"() {
given:
buildFile << """
def mojoSourceSet = sourceSets.create('mojo')
mavenPlugin {
pluginSourceSet = mojoSourceSet
}
dependencies {
mojoImplementation 'org.apache.maven:maven-plugin-api:3.6.3'
mojoImplementation 'org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0'
}
"""
javaMojo("mojo")

when:
run("generateMavenPluginDescriptor")

then:
pluginDescriptor()
helpDescriptor()
}

def "adds direct and transitive runtime dependencies to plugin descriptor"() {
given:
buildFile << """
Expand Down

0 comments on commit 1f31e89

Please sign in to comment.