Skip to content
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ plugins {

// Any callers need to have this repository too.
repositories {
maven { url 'https://clojars.org/repo' }
maven { url = 'https://clojars.org/repo' }
mavenCentral()
}

description 'Small wrapper around clojuresque'
description = 'Small wrapper around clojuresque'

contacts {
'[email protected]' {
Expand Down
21 changes: 15 additions & 6 deletions src/main/groovy/nebula/plugin/clojuresque/ClojureBasePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,19 @@ class ClojureBasePlugin implements Plugin<Project> {
from project.file("src/${set.name}/clojure")
aotCompile.set(extension.aotCompile)
warnOnReflection.set(extension.warnOnReflection)
classpath.from(
set.compileClasspath,
project.configurations.findByName('development')?.incoming?.files
)
classpath.from(set.compileClasspath)
def developmentConfig = project.configurations.findByName('development')
if (developmentConfig != null) {
classpath.from(developmentConfig)
}
destinationDir.set(
findOutputDir(set)
)
description = "Compile the ${set.name} Clojure source."
}
project.tasks[set.classesTaskName].dependsOn task
project.tasks.named(set.classesTaskName).configure {
dependsOn task
}
}
}

Expand All @@ -103,6 +106,10 @@ class ClojureBasePlugin implements Plugin<Project> {
classpath.from(
set.compileClasspath
)
projectName.set(project.name)
projectDescription.set(project.provider { project.description ?: "" })
projectVersion.set(project.provider { project.version?.toString() ?: "" })
projectDirectory.set(project.layout.projectDirectory)
description = "Generate documentation for the Clojure source."
group = JavaBasePlugin.DOCUMENTATION_GROUP
}
Expand Down Expand Up @@ -131,7 +138,9 @@ class ClojureBasePlugin implements Plugin<Project> {
enabled = false
}
}
project.tasks.test.dependsOn clojureTest
project.tasks.named('test').configure {
dependsOn clojureTest
}
}

private void configureRun(Project project, JavaPluginExtension javaPluginExtension) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import org.gradle.api.Project

public class ClojureCommonPlugin implements Plugin<Project> {
void apply(Project project) {

project.configurations {
development {
transitive = true
visible = false
description = "Development only dependencies"
}
project.configurations.register("development") { conf ->
conf.setCanBeConsumed(false)
conf.setCanBeResolved(true)
conf.setTransitive(true)
conf.setVisible(false)
conf.setDescription("Development only dependencies")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import org.gradle.api.file.FileType
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.CompileClasspath
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.StopExecutionException
import org.gradle.api.tasks.TaskAction
Expand All @@ -45,7 +46,7 @@ abstract class ClojureCompile extends ClojureSourceTask {
abstract Property<File> getDestinationDir()

@InputFiles
@Classpath
@CompileClasspath
Copy link
Member

Choose a reason for hiding this comment

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

ooo what is this?

Copy link
Member Author

@rpalcolea rpalcolea Dec 1, 2025

Choose a reason for hiding this comment

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

https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/CompileClasspath.html we probably won't get a lot of the benefits but maybe a few

abstract ConfigurableFileCollection getClasspath()

@Input
Expand All @@ -54,11 +55,13 @@ abstract class ClojureCompile extends ClojureSourceTask {
@Input
abstract Property<Boolean> getWarnOnReflection()

@Internal
def dirMode = null
@Internal
def fileMode = null
@Input
@Optional
abstract Property<Integer> getDirMode()

@Input
@Optional
abstract Property<Integer> getFileMode()

private final ExecOperations execOperations

Expand Down Expand Up @@ -144,22 +147,24 @@ abstract class ClojureCompile extends ClojureSourceTask {

if (aotCompile.isPresent() && !aotCompile.get()) {
fileSystemOperations.copy {
if(this.dirMode != null) {
if(this.dirMode.isPresent()) {
def dirModeValue = this.dirMode.get()
if(isOlderThanGradle8_3()) {
dirMode = this.dirMode
dirMode = dirModeValue
} else {
dirPermissions {
unix(this.dirMode)
unix(dirModeValue)
}
}
}

if(this.fileMode != null) {
if(this.fileMode.isPresent()) {
def fileModeValue = this.fileMode.get()
if(isOlderThanGradle8_3()) {
fileMode = this.fileMode
fileMode = fileModeValue
} else {
filePermissions {
unix(this.fileMode)
unix(fileModeValue)
}
}
}
Expand Down
43 changes: 34 additions & 9 deletions src/main/groovy/nebula/plugin/clojuresque/tasks/ClojureDoc.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ package nebula.plugin.clojuresque.tasks
import nebula.plugin.clojuresque.Util

import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.StopExecutionException
import org.gradle.api.tasks.TaskAction
import org.gradle.process.ExecOperations
Expand All @@ -40,13 +46,32 @@ abstract class ClojureDoc extends ClojureSourceTask {

@Input
@Optional
def codox = [:]
abstract MapProperty<String, Object> getCodox()

@Input
abstract Property<String> getProjectName()

@Input
abstract Property<String> getProjectDescription()

@Input
abstract Property<String> getProjectVersion()

@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
abstract DirectoryProperty getProjectDirectory()

private final ExecOperations execOperations
private final ObjectFactory objectFactory

@Inject
ClojureDoc(ExecOperations execOperations) {
ClojureDoc(ExecOperations execOperations, ObjectFactory objectFactory) {
this.execOperations = execOperations
this.objectFactory = objectFactory
codox.convention([:])
projectName.convention("")
projectDescription.convention("")
projectVersion.convention("")
}

@TaskAction
Expand All @@ -60,13 +85,13 @@ abstract class ClojureDoc extends ClojureSourceTask {
def options = [
destinationDir: destDir.path,
project: [
name: project.name ?: "",
description: project.description ?: "",
version: project.version ?: ""
name: projectName.get(),
description: projectDescription.get(),
version: projectVersion.get()
],
codox: codox,
codox: codox.get(),
sourceDirs: srcDirs.files.collect {
relativize(it, project.projectDir)
relativize(it, projectDirectory.get().asFile)
},
sourceFiles: source*.path
]
Expand All @@ -89,7 +114,7 @@ abstract class ClojureDoc extends ClojureSourceTask {
execOperations.javaexec {
setMainClass("clojure.main")
args('-')
classpath = project.files(
classpath = objectFactory.fileCollection().from(
this.srcDirs,
this.classpath
)
Expand All @@ -108,7 +133,7 @@ abstract class ClojureDoc extends ClojureSourceTask {
"js/page_effects.js",
"js/jquery.min.js"
].each { f ->
def dest = project.file("${destinationDir}/${f}")
def dest = new File(destinationDir.get(), f)
println "${f}"
if (!dest.exists()) {
dest.parentFile.mkdirs()
Expand Down
15 changes: 11 additions & 4 deletions src/main/groovy/nebula/plugin/clojuresque/tasks/ClojureRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import nebula.plugin.clojuresque.Util
import nebula.plugin.utils.tasks.ConfigureUtil
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.options.Option
import org.gradle.process.ExecOperations
Expand All @@ -18,32 +19,38 @@ abstract class ClojureRun extends ClojureSourceTask {
@Classpath
abstract ConfigurableFileCollection getClasspath()

private String fn;
@Input
@Optional
abstract Property<String> getFn()

@Option(option = "fn", description = "The clojure function (and optional args) to execute.")
public void setFn(String fn) {
this.fn = fn;
this.getFn().set(fn)
}

private final ExecOperations execOperations

private final ObjectFactory objects

@Internal
def jvmOptions = {}
Closure jvmOptions = {}

@Inject
ClojureRun(ExecOperations execOperations, ObjectFactory objects) {
this.execOperations = execOperations
this.objects = objects
}

void jvmOptions(Closure closure) {
this.jvmOptions = closure
}

// Example usage: ./gradlew clojureRun --fn='my-ns/my-fn arg1 arg2'
@TaskAction
void run() {

def options = [
fn: fn
fn: fn.getOrNull()
]

def runtime = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ abstract class ClojureTest extends ClojureSourceTask {
private final ObjectFactory objects

@Internal
def jvmOptions = {}
Closure jvmOptions = {}

@Inject
ClojureTest(ExecOperations execOperations, ObjectFactory objects) {
this.execOperations = execOperations
this.objects = objects
}

void jvmOptions(Closure closure) {
this.jvmOptions = closure
}

@TaskAction
void runTests() {
def junitDir = junitOutputDir.isPresent() ? junitOutputDir.get() : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class SourceDirectoryTask extends DefaultTask {
@InputFiles
@SkipWhenEmpty
@IgnoreEmptyDirectories
@PathSensitive(PathSensitivity.NONE)
@PathSensitive(PathSensitivity.RELATIVE)
def FileTree getSource() {
objectFactory.fileCollection().from(srcDirs).asFileTree
}
Expand Down
Loading