-
Notifications
You must be signed in to change notification settings - Fork 127
Provider API and Configuration Cache Support #477
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
Changes from all commits
2085a05
1270cd4
85618a1
0faf5ea
3ee34dc
986045a
4d30f43
2cbbbf8
41f20f2
408edac
a6fd9d1
34b8884
863ff58
96fc7c1
7d28015
b6a5753
6830d2b
3706042
45da4c1
590a4d0
b9675b2
69a99c6
0fe1444
b9dbecf
463614e
e1d633c
7c90267
14ba1f2
a05b187
701fcfc
bf09fb3
f825db5
628e32e
e605948
a01759a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ out | |
| *.iml | ||
| *.iws | ||
| .idea | ||
| .claude/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,6 @@ import org.gradle.api.Action | |
| import org.gradle.api.Plugin | ||
| import org.gradle.api.Project | ||
| import org.gradle.api.Task | ||
| import org.gradle.api.internal.IConventionAware | ||
| import org.gradle.api.plugins.ApplicationPlugin | ||
|
|
||
| /** | ||
|
|
@@ -45,36 +44,41 @@ class OspackageApplicationPlugin implements Plugin<Project> { | |
| OspackageApplicationExtension extension | ||
|
|
||
| @Override | ||
| @CompileDynamic | ||
| void apply(Project project) { | ||
| extension = project.extensions.create('ospackage_application', OspackageApplicationExtension) | ||
| def conventionMapping = ((IConventionAware) extension).conventionMapping | ||
| conventionMapping.map('prefix') { '/opt' } | ||
| conventionMapping.map('distribution') { '' } | ||
|
|
||
| // Set convention (default) values using Property API | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd have Claude strip these comments that are obvious. |
||
| extension.prefix.convention('/opt') | ||
| extension.distribution.convention('') | ||
|
|
||
| project.plugins.apply(ApplicationPlugin) | ||
| project.plugins.apply(SystemPackagingPlugin) | ||
|
|
||
| project.afterEvaluate { | ||
| final installTask = project.tasks.getByName("install${extension.distribution.capitalize()}Dist") | ||
| def packagingExt = project.extensions.getByType(ProjectPackagingExtension) | ||
| packagingExt.from { | ||
| installTask.outputs.files.singleFile.parent | ||
| } | ||
| def packagingExt = project.extensions.getByType(ProjectPackagingExtension) | ||
|
|
||
| packagingExt.into(extension.getPrefix()) | ||
| // Configure packaging extension - use provider for lazy evaluation | ||
| packagingExt.from(project.provider { | ||
| def distributionName = extension.distribution.getOrElse('') | ||
| def installTask = project.tasks.named("install${distributionName.capitalize()}Dist") | ||
| installTask.get().outputs.files.singleFile.parent | ||
| }) | ||
|
|
||
| linkInstallToPackageTask(project, Deb, installTask) | ||
| linkInstallToPackageTask(project, Rpm, installTask) | ||
| } | ||
| // Pass the Property directly to into() | ||
| packagingExt.into(extension.prefix.map { it }) | ||
|
|
||
| // Link install task to package tasks lazily | ||
| linkInstallToPackageTasks(project, Deb) | ||
| linkInstallToPackageTasks(project, Rpm) | ||
| } | ||
|
|
||
| @CompileDynamic | ||
| private <T extends Class> void linkInstallToPackageTask(Project project, T type, Task installTask) { | ||
| project.tasks.withType(type).configureEach(new Action<SystemPackagingTask>() { | ||
| @Override | ||
| void execute(SystemPackagingTask task) { | ||
| task.dependsOn(installTask) | ||
| } | ||
| }) | ||
| private <T extends Class> void linkInstallToPackageTasks(Project project, T type) { | ||
| project.tasks.withType(type).configureEach { SystemPackagingTask task -> | ||
| // Use TaskProvider for type-safe lazy task dependency | ||
| def distributionName = extension.distribution.getOrElse('') | ||
| def installTaskName = "install${distributionName.capitalize()}Dist" | ||
| task.dependsOn(project.tasks.named(installTaskName)) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,8 +53,16 @@ class OspackageApplicationSpringBootPlugin implements Plugin<Project> { | |
| void apply(Project project) { | ||
| project.plugins.apply(OspackageApplicationPlugin) | ||
|
|
||
| // Validate Spring Boot plugin at configuration time using plugins.withId | ||
| // This automatically waits for plugin application | ||
| boolean springBootFound = false | ||
| project.plugins.withId("org.springframework.boot") { | ||
| springBootFound = true | ||
| } | ||
|
|
||
| // Only validate after other plugins have a chance to apply | ||
| project.afterEvaluate { | ||
| if (!project.plugins.hasPlugin('org.springframework.boot')) { | ||
| if (!springBootFound) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Believe this can be |
||
| project.logger.error("The '{}' plugin requires the '{}' plugin.", | ||
| "com.netflix.nebula.ospackage-application-spring-boot", | ||
| "org.springframework.boot") | ||
|
|
@@ -137,8 +145,10 @@ class OspackageApplicationSpringBootPlugin implements Plugin<Project> { | |
| main { | ||
| contents { | ||
| into('lib') { | ||
| project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).files.findAll { file -> | ||
| file.getName() != project.tasks.getByName(JavaPlugin.JAR_TASK_NAME).outputs.files.singleFile.name | ||
| def jarTaskProvider = project.tasks.named(JavaPlugin.JAR_TASK_NAME) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use |
||
| def runtimeClasspath = project.configurations.named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) | ||
| runtimeClasspath.get().files.findAll { file -> | ||
| file.getName() != jarTaskProvider.get().outputs.files.singleFile.name | ||
| }.each { file -> | ||
| exclude file.name | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,49 +16,52 @@ | |
|
|
||
| package com.netflix.gradle.plugins.daemon | ||
|
|
||
| import org.gradle.api.internal.ConventionTask | ||
| import org.gradle.api.DefaultTask | ||
| import org.gradle.api.file.DirectoryProperty | ||
| import org.gradle.api.provider.ListProperty | ||
| import org.gradle.api.provider.MapProperty | ||
| import org.gradle.api.provider.Property | ||
| import org.gradle.api.tasks.Input | ||
| import org.gradle.api.tasks.InputFile | ||
| import org.gradle.api.tasks.Internal | ||
| import org.gradle.api.tasks.Optional | ||
| import org.gradle.api.tasks.OutputFiles | ||
| import org.gradle.api.tasks.OutputDirectory | ||
| import org.gradle.api.tasks.TaskAction | ||
| import org.gradle.work.DisableCachingByDefault | ||
|
|
||
| /** | ||
| * Monster class that does everything. | ||
| */ | ||
| @DisableCachingByDefault | ||
| class DaemonTemplateTask extends ConventionTask { | ||
|
|
||
| DaemonTemplateTask() { | ||
| notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache") | ||
| } | ||
| abstract class DaemonTemplateTask extends DefaultTask { | ||
|
|
||
| @Internal | ||
| Map<String, String> context | ||
| abstract MapProperty<String, Object> getContext() | ||
|
|
||
| @Internal | ||
| Collection<String> templates | ||
| abstract ListProperty<String> getTemplates() | ||
|
|
||
| @OutputDirectory | ||
| abstract DirectoryProperty getDestDir() | ||
|
|
||
| @Internal | ||
| File destDir | ||
| abstract Property<String> getTemplatesFolder() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! I kept it as
And then the |
||
|
|
||
| @Internal | ||
| String templatesFolder | ||
| abstract Property<File> getProjectDirectory() | ||
|
|
||
| @TaskAction | ||
| def template() { | ||
| TemplateHelper templateHelper = new TemplateHelper(getDestDir(), getTemplatesFolder(), project) | ||
| getTemplates().collect { String templateName -> | ||
| templateHelper.generateFile(templateName, getContext()) | ||
| } | ||
| DaemonTemplateTask() { | ||
| // Capture project directory during configuration | ||
| projectDirectory.convention(project.projectDir) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should use |
||
| } | ||
|
|
||
| @Internal | ||
| Collection<File> getTemplatesOutput() { | ||
| return templates.collect { | ||
| new File(destDir, it) | ||
| @TaskAction | ||
| def template() { | ||
| TemplateHelper templateHelper = new TemplateHelper( | ||
| destDir.get().asFile, | ||
| templatesFolder.get(), | ||
| projectDirectory.get() | ||
| ) | ||
| templates.get().collect { String templateName -> | ||
| templateHelper.generateFile(templateName, context.get()) | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.claudeis intended to be checked in, so maybe:https://code.claude.com/docs/en/memory#determine-memory-type