-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gradle): wrap looping through task inside projectsEvaluated
- Loading branch information
Showing
16 changed files
with
291 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
* | ||
* The settings file is used to specify which projects to include in your build. | ||
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.5/userguide/building_swift_projects.html in the Gradle documentation. | ||
*/ | ||
|
||
|
||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "native" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 13 additions & 47 deletions
60
packages/gradle/native/src/main/kotlin/dev/nx/gradle/native/NodesPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,35 @@ | ||
package dev.nx.gradle.native | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.Plugin | ||
import com.google.gson.Gson | ||
import org.gradle.api.Project | ||
|
||
/** | ||
* A plugin to create nx nodes, dependencies and external nodes | ||
*/ | ||
class NodesPlugin : Plugin<Project> { | ||
|
||
override fun apply(project: Project) { | ||
project.logger.info("HELLO") | ||
val gradleNodeReport = project.objects.property(GradleNodeReport::class.java) | ||
|
||
// Initialize and store data in GradleNodeReport safely | ||
project.gradle.projectsEvaluated { | ||
val report = createNodeForProject(project) | ||
gradleNodeReport.set(report) | ||
} | ||
|
||
// Register a task | ||
project.tasks.register("createNodes", CreateNodesTask::class.java) { task -> | ||
val gradleNodeReport = createNodeForProject(project) | ||
|
||
task.projectName = project.name | ||
val gson = Gson() | ||
val json = gson.toJson(gradleNodeReport) | ||
task.json = json | ||
task.gradleNodeReport.set(gradleNodeReport) | ||
|
||
task.setDescription("Create nodes and dependencies for Nx") | ||
task.setGroup("Nx Custom") | ||
task.description = "Create nodes and dependencies for Nx" | ||
task.group = "Nx Custom" | ||
|
||
// Run task for composite builds | ||
project.getGradle().includedBuilds.forEach { includedBuild -> | ||
project.gradle.includedBuilds.forEach { includedBuild -> | ||
task.dependsOn(includedBuild.task(":createNodes")) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Loops through all projects and populate dependencies and nodes for each target | ||
*/ | ||
fun createNodeForProject(rootProject: Project): GradleNodeReport { | ||
val gradleNodeReport = GradleNodeReport(null, null, null) | ||
val logger = rootProject.getLogger() | ||
logger.info("createNodeForProject: get nodes and dependencies for ${rootProject}") | ||
|
||
try { | ||
// get dependencies of project | ||
val dependencies = getDependenciesForProject(rootProject, rootProject.getAllprojects()) | ||
gradleNodeReport.dependencies = dependencies | ||
logger.info("createNodeForProject: get dependencies for ${rootProject}") | ||
} catch (e: Exception) { | ||
logger.info("createNodeForProject: get dependencies error ${e.toString()}") | ||
} | ||
|
||
|
||
try { | ||
val gradleTargets: GradleTargets = processTargetsForProject(rootProject) | ||
var projectRoot = rootProject.getProjectDir().getPath() | ||
val projectNode = ProjectNode( | ||
gradleTargets.targets, | ||
NodeMetadata(gradleTargets.targetGroups, arrayOf("gradle"), rootProject.getDescription()), | ||
rootProject.getName() | ||
) | ||
gradleNodeReport.nodes = mutableMapOf<String, ProjectNode>(projectRoot to projectNode) | ||
|
||
gradleNodeReport.externalNodes = gradleTargets.externalNodes | ||
logger.info("CreateNodes: get nodes and external nodes for ${projectRoot}") | ||
} catch (e: Exception) { | ||
logger.info("${rootProject}: get nodes error ${e.toString()}") | ||
} | ||
return gradleNodeReport | ||
} | ||
} | ||
|
Oops, something went wrong.