Skip to content
Merged
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
21 changes: 13 additions & 8 deletions src/main/resources/init-script-gradle.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import org.gradle.api.Task
import org.gradle.api.execution.TaskExecutionListener
import org.gradle.api.tasks.TaskState

Set<String> projectNameExcludeFilter = convertStringToSet('${excludedProjectNames}')
Set<String> projectNameIncludeFilter = convertStringToSet('${includedProjectNames}')
Set<String> projectPathExcludeFilter = convertStringToSet('${excludedProjectPaths}')
Set<String> projectPathIncludeFilter = convertStringToSet('${includedProjectPaths}')
Set<String> projectNameExcludeFilter = convertStringToSet('${excludedProjectNames?replace("\\", "\\\\")?replace("\'", "\\\'")}')
Set<String> projectNameIncludeFilter = convertStringToSet('${includedProjectNames?replace("\\", "\\\\")?replace("\'", "\\\'")}')
Set<String> projectPathExcludeFilter = convertStringToSet('${excludedProjectPaths?replace("\\", "\\\\")?replace("\'", "\\\'")}')
Set<String> projectPathIncludeFilter = convertStringToSet('${includedProjectPaths?replace("\\", "\\\\")?replace("\'", "\\\'")}')
Boolean rootOnly = Boolean.parseBoolean("${rootOnlyOption}")

gradle.allprojects {
Expand Down Expand Up @@ -47,9 +47,11 @@ gradle.allprojects {
def projectVersion = currentProject.version.toString()
def projectParent = currentProject.parent ? currentProject.parent.toString() : "none"

// Prepare configuration names
// Prepare configuration names (handles single quotes issues )
def configurationNames = getFilteredConfigurationNames(currentProject,
'${excludedConfigurationNames}', '${includedConfigurationNames}')
'${excludedConfigurationNames?replace("\\", "\\\\")?replace("\'", "\\\'")}',
'${includedConfigurationNames?replace("\\", "\\\\")?replace("\'", "\\\'")}'
)

def selectedConfigs = []
configurationNames.each { name ->
Expand All @@ -64,11 +66,14 @@ gradle.allprojects {
}
}

// Check if the project should be included in results
def shouldIncludeProject = (rootOnly && isRootProject) ||
// Check if the project should be included based on project-level filters
def projectMatchesFilters = (rootOnly && isRootProject) ||
(!rootOnly && shouldInclude(projectNameExcludeFilter, projectNameIncludeFilter, projectName) &&
shouldInclude(projectPathExcludeFilter, projectPathIncludeFilter, projectPath))

// A project is only included if it matches project filters AND has configurations that match config filters.
def shouldIncludeProject = projectMatchesFilters && !selectedConfigs.isEmpty()

// Capture output file path during configuration
def projectFilePathConfig = computeProjectFilePath(projectPath, extractionDir, rootProject)

Expand Down