nx/packages/gradle/project-graph/build.gradle.kts
Emily Xiong b377c96d99
feat(java): add gradle kotlin plugin (#29464)
- [x] change init to create `createNodes` instead
- [x] unit tests
- [x] test-ci
- [x] test on windows
- [x] help metadata
- [x] external nodes

TODO:
- add publish executor?
- publish to maven central?

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
currently, it uses [project report
plugin](https://docs.gradle.org/current/userguide/project_report_plugin.html).
- pro: no need to maintain this plugin
- con: this plugin gives limited information

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
change the project report plugin to @nxn/gradle/plugin-v1
now the @nx/gradle plugin will use project graph plugin
(dev.nx.gradle.project-graph) created in this pr.
this plugin will create json file that is exactly what nx project grpah
expected.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-04-23 13:13:25 -04:00

121 lines
3.1 KiB
Plaintext

plugins {
`java-gradle-plugin`
`maven-publish`
signing
id("com.ncorti.ktfmt.gradle") version "+"
id("dev.nx.gradle.project-graph") version "0.0.2"
id("org.jetbrains.kotlin.jvm") version "2.1.10"
id("com.gradle.plugin-publish") version "1.2.1"
}
group = "dev.nx.gradle"
version = "0.0.2"
repositories { mavenCentral() }
dependencies {
implementation("com.google.code.gson:gson:2.10.1")
testImplementation(kotlin("test"))
testImplementation("org.mockito:mockito-core:5.8.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
}
java {
withSourcesJar()
withJavadocJar()
}
gradlePlugin {
website = "https://nx.dev/"
vcsUrl = "https://github.com/nrwl/nx"
plugins {
create("nxProjectGraphPlugin") {
id = "dev.nx.gradle.project-graph"
implementationClass = "dev.nx.gradle.NxProjectGraphReportPlugin"
displayName = "The Nx Plugin for Gradle to generate Nx project graph"
description = "Generates a JSON file with nodes, dependencies, and external nodes for Nx"
tags = listOf("nx", "monorepo", "javascript", "typescript")
}
}
}
afterEvaluate {
publishing {
publications.named("pluginMaven", MavenPublication::class) {
pom {
name.set("Nx Gradle Project Graph Plugin")
description.set(
"A plugin to generate a JSON file with nodes, dependencies, and external nodes for Nx")
url.set("https://github.com/nrwl/nx")
licenses { license { name.set("MIT") } }
developers {
developer {
id.set("nx")
name.set("Nx")
email.set("java-services@nrwl.io")
}
}
scm {
connection.set("scm:git:git://github.com/nrwl/nx.git")
developerConnection.set("scm:git:ssh://github.com/nrwl/nx.git")
url.set("https://github.com/nrwl/nx")
}
}
}
repositories {
maven {
name = "localStaging"
url = uri(layout.buildDirectory.dir("staging"))
}
}
}
publishing {
publications.named("nxProjectGraphPluginPluginMarkerMaven", MavenPublication::class) {
pom {
name.set("Nx Gradle Project Graph Plugin")
description.set(
"A plugin to generate a JSON file with nodes, dependencies, and external nodes for Nx")
url.set("https://github.com/nrwl/nx")
licenses { license { name.set("MIT") } }
developers {
developer {
id.set("nx")
name.set("Nx")
email.set("java-services@nrwl.io")
}
}
scm {
connection.set("scm:git:git://github.com/nrwl/nx.git")
developerConnection.set("scm:git:ssh://github.com/nrwl/nx.git")
url.set("https://github.com/nrwl/nx")
}
repositories {
maven {
name = "localStaging"
url = uri(layout.buildDirectory.dir("staging"))
}
}
}
}
}
}
signing {
afterEvaluate {
sign(publishing.publications["pluginMaven"])
sign(publishing.publications["nxProjectGraphPluginPluginMarkerMaven"])
}
}
tasks.test { useJUnitPlatform() }