I am able to identify if a gradle project has applied java/ java-library/ application/ java-platform plugins in the build.gradle if they are applied directly.
However there is no way to identify the same if there are other plugins being used which uses java plugins indirectly.
Question : how can i successfully identify if a gradle project is a pure java project (and not say scala/or kotlin projects,etc)
For example take a look at the below build.gradle file
I am using org.springframework.boot plugins and it is a java source code .
plugins {
id 'io.spring.nohttp'
id 'org.springframework.pulsar.root-project'
id 'org.springframework.pulsar.update-version'
id 'org.ajoberstar.grgit' version '4.0.1' apply false
id "org.springframework.boot" version "3.2.0-SNAPSHOT"
id 'io.spring.dependency-management' version '1.1.0'
}
description = 'Spring for Apache Pulsar'
apply from: 'gradle/aggregate-jacoco-report.gradle'
apply from: 'gradle/update-copyrights.gradle'
allprojects {
group = 'org.springframework.pulsar'
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, "seconds"
cacheDynamicVersionsFor 0, "seconds"
}
}
}
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
nohttp {
allowlistFile = project.file('src/nohttp/allowlist.lines')
source.exclude "**/bin/**"
source.exclude "**/build/**"
source.exclude "**/out/**"
source.exclude "**/target/**"
source.exclude "**/*.dylib"
source.exclude "**/*.gif"
source.exclude "**/.gradle/**"
}
check {
dependsOn checkstyleNohttp
}
I am able to run gradlew compileJava command successfully, however when i try to locate the compileJava tasks by running gradlew tasks it does not appear.
When i use the below groovy code , even then it does not appear.
println "Found task: ${project.tasks.findByPath('Jar')} ${project.findProperty('compileJava')} ${project.findProperty('JavaCompile')}"
If i use the below groovy code,
println "${project.plugins}"
i get the following output,
[org.gradle.api.plugins.HelpTasksPlugin$Inject@4d9e0c94, org.gradle.buildinit.plugins.BuildInitPlugin$Inject@3deb5450, org.gradle.buildinit.plugins.WrapperPlugin$Inject@3739ab18, org.gradle.api.plugins.ReportingBasePlugin$Inject@38e2508, org.gradle.api.plugins.quality.CheckstylePlugin$Inject@114f8c2a, io.spring.nohttp.gradle.NoHttpCheckstylePlugin@42bf2747, io.spring.nohttp.gradle.NoHttpCliPlugin@2f7ccde6, io.spring.nohttp.gradle.NoHttpPlugin@6482f523, org.gradle.language.base.plugins.LifecycleBasePlugin$Inject@968d5e8, org.gradle.api.plugins.BasePlugin$Inject@4a444d03, io.github.gradlenexus.publishplugin.NexusPublishPlugin@67a88d76, org.springframework.pulsar.gradle.publish.SpringNexusPublishPlugin@6385273f, org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin@36ddd78d, io.spring.gradle.convention.ArtifactoryPlugin@d18d5cd, org.sonarqube.gradle.SonarQubePlugin@144353eb, org.springframework.pulsar.gradle.check.SonarQubeConventionsPlugin@32d9d657, org.springframework.pulsar.gradle.RootProjectPlugin@1f0cbc2f, org.springframework.pulsar.gradle.versions.UpdateProjectVersionPlugin@4d7f5ab4, org.springframework.boot.gradle.plugin.SpringBootPlugin@30a313be, io.spring.gradle.dependencymanagement.DependencyManagementPlugin@1f319d9b, org.gradle.testing.jacoco.plugins.JacocoPlugin$Inject@54d9b30e, org.ajoberstar.grgit.gradle.GrgitPlugin@1aa6025d]