Skip to content
Snippets Groups Projects
Commit 327d5467 authored by Nicholas Blair's avatar Nicholas Blair
Browse files

feat: always populate MANIFEST with project.name and .version

parent 2a0d10e0
No related branches found
No related tags found
1 merge request!2feat: always populate MANIFEST with project.name and .version
group 'edu.wisc.doit.gradle'
version '0.1.1'
version '0.2.0'
apply plugin: 'groovy'
apply plugin: 'idea'
......@@ -26,7 +26,14 @@ publishing {
}
}
}
jar {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
)
}
}
uploadArchives {
repositories {
mavenDeployer {
......
......@@ -2,6 +2,7 @@ package edu.wisc.doit.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
/**
* Root Gradle {@link Plugin} class.
......@@ -19,5 +20,28 @@ class ContinuousPublishPlugin implements Plugin<Project> {
project.getTasks()
.create("confirmProjectVersionIncremented",
ConfirmProjectVersionIncrementedTask.class)
// findByName can return null; getByName throws UnknownTaskException
configureManifest(project.getTasks().findByName("jar"))
configureManifest(project.getTasks().findByName("war"))
}
/**
* Set 'Implementation-Title' and 'Implementation-Version' attributes
* in the task's manifest
*
* See https://docs.oracle.com/javase/tutorial/deployment/jar/packageman.html
*
* @param task the task to configure (null safe)
*/
void configureManifest(Task task) {
task?.configure {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version
)
}
}
}
}
......@@ -16,6 +16,7 @@ class ContinuousPublishPluginTest {
@Test
public void pluginAddsTaskToProject() {
Project project = ProjectBuilder.builder().build()
project.pluginManager.apply 'java'
project.pluginManager.apply 'edu.wisc.doit.gradle.continuous-publish-plugin'
assertTrue(project.tasks.confirmProjectVersionIncremented instanceof ConfirmProjectVersionIncrementedTask)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment