Search in sources :

Example 1 with GradleInspectorScriptOptions

use of com.synopsys.integration.detectable.detectables.gradle.inspection.inspector.GradleInspectorScriptOptions in project synopsys-detect by blackducksoftware.

the class DetectableOptionFactory method createGradleInspectorOptions.

public GradleInspectorOptions createGradleInspectorOptions() {
    List<String> excludedProjectNames = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_EXCLUDED_PROJECTS);
    List<String> includedProjectNames = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_INCLUDED_PROJECTS);
    List<String> excludedProjectPaths = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_EXCLUDED_PROJECT_PATHS);
    List<String> includedProjectPaths = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_INCLUDED_PROJECT_PATHS);
    List<String> excludedConfigurationNames = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_EXCLUDED_CONFIGURATIONS);
    List<String> includedConfigurationNames = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_INCLUDED_CONFIGURATIONS);
    String customRepository = ArtifactoryConstants.GRADLE_INSPECTOR_MAVEN_REPO;
    EnumListFilter<GradleConfigurationType> dependencyTypeFilter;
    if (detectConfiguration.wasPropertyProvided(DetectProperties.DETECT_GRADLE_CONFIGURATION_TYPES_EXCLUDED)) {
        Set<GradleConfigurationType> excludedConfigurationTypes = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_CONFIGURATION_TYPES_EXCLUDED).representedValueSet();
        dependencyTypeFilter = EnumListFilter.fromExcluded(excludedConfigurationTypes);
    } else {
        boolean includeUnresolvedConfigurations = detectConfiguration.getValue(DetectProperties.DETECT_GRADLE_INCLUDE_UNRESOLVED_CONFIGURATIONS);
        if (includeUnresolvedConfigurations) {
            dependencyTypeFilter = EnumListFilter.excludeNone();
        } else {
            dependencyTypeFilter = EnumListFilter.fromExcluded(GradleConfigurationType.UNRESOLVED);
        }
    }
    String onlineInspectorVersion = detectConfiguration.getNullableValue(DetectProperties.DETECT_GRADLE_INSPECTOR_VERSION);
    GradleInspectorScriptOptions scriptOptions = new GradleInspectorScriptOptions(excludedProjectNames, includedProjectNames, excludedProjectPaths, includedProjectPaths, excludedConfigurationNames, includedConfigurationNames, customRepository, onlineInspectorVersion);
    String gradleBuildCommand = detectConfiguration.getNullableValue(DetectProperties.DETECT_GRADLE_BUILD_COMMAND);
    return new GradleInspectorOptions(gradleBuildCommand, scriptOptions, proxyInfo, dependencyTypeFilter);
}
Also used : GradleConfigurationType(com.synopsys.integration.detectable.detectables.gradle.inspection.GradleConfigurationType) GradleInspectorOptions(com.synopsys.integration.detectable.detectables.gradle.inspection.GradleInspectorOptions) GradleInspectorScriptOptions(com.synopsys.integration.detectable.detectables.gradle.inspection.inspector.GradleInspectorScriptOptions)

Example 2 with GradleInspectorScriptOptions

use of com.synopsys.integration.detectable.detectables.gradle.inspection.inspector.GradleInspectorScriptOptions in project synopsys-detect by blackducksoftware.

the class GradleInspectorScriptCreatorTest method testOffline.

@Test
void testOffline() throws DetectableException, IOException {
    List<String> excludedProjectNames = Arrays.asList("excludedProject");
    List<String> includedProjectNames = Arrays.asList("includedProject");
    List<String> excludedConfigurationNames = Arrays.asList("excludedConfig");
    List<String> includedConfigurationNames = Arrays.asList("excludedConfig");
    String gradleInspectorRepositoryUrl = null;
    String providedOnlineInspectorVersion = null;
    GradleInspectorScriptOptions scriptOptions = new GradleInspectorScriptOptions(excludedProjectNames, includedProjectNames, Collections.emptyList(), Collections.emptyList(), excludedConfigurationNames, includedConfigurationNames, gradleInspectorRepositoryUrl, providedOnlineInspectorVersion);
    Configuration configuration = createFreemarkerConfiguration();
    GradleInspectorScriptCreator gradleInspectorScriptCreator = new GradleInspectorScriptCreator(configuration);
    File targetFile = new File(tempDir, "init-detect.gradle");
    String airGapLibraryPaths = "airGap/library/dir";
    gradleInspectorScriptCreator.createOfflineGradleInspector(targetFile, scriptOptions, airGapLibraryPaths);
    String generatedScriptContent = FileUtils.readFileToString(targetFile, StandardCharsets.UTF_8);
    assertTrue(generatedScriptContent.contains("dirs 'airGap/library/dir'"));
    assertTrue(generatedScriptContent.contains("File('airGap/library/dir').eachFile"));
}
Also used : GradleInspectorScriptCreator(com.synopsys.integration.detectable.detectables.gradle.inspection.inspector.GradleInspectorScriptCreator) Configuration(freemarker.template.Configuration) GradleInspectorScriptOptions(com.synopsys.integration.detectable.detectables.gradle.inspection.inspector.GradleInspectorScriptOptions) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

GradleInspectorScriptOptions (com.synopsys.integration.detectable.detectables.gradle.inspection.inspector.GradleInspectorScriptOptions)2 GradleConfigurationType (com.synopsys.integration.detectable.detectables.gradle.inspection.GradleConfigurationType)1 GradleInspectorOptions (com.synopsys.integration.detectable.detectables.gradle.inspection.GradleInspectorOptions)1 GradleInspectorScriptCreator (com.synopsys.integration.detectable.detectables.gradle.inspection.inspector.GradleInspectorScriptCreator)1 Configuration (freemarker.template.Configuration)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1