Search in sources :

Example 11 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class NugetRun method singleProjectHandler.

private void singleProjectHandler(String projectName, String csprojPath, String globalCachePath) throws Exception {
    String dependenciesSource = getDependenciesSource(projectName, csprojPath);
    if (StringUtils.isEmpty(dependenciesSource)) {
        logger.debug("Project dependencies was not found for project: " + projectName);
        return;
    }
    // Collect dependencies according to the correct method:
    // Check if project uses packages.config or project.assets.json
    List<Dependency> dependencies = new ArrayList<>();
    if (dependenciesSource.endsWith(PACKAGES_CONFIG)) {
        dependencies = collectDependenciesFromPackagesConfig(dependenciesSource, globalCachePath);
    } else if (dependenciesSource.endsWith(PROJECT_ASSETS)) {
        dependencies = collectDependenciesFromProjectAssets(dependenciesSource);
    }
    Module projectModule = new ModuleBuilder().type(ModuleType.NUGET).id(projectName).dependencies(dependencies).build();
    if (StringUtils.isBlank(module)) {
        modulesList.add(projectModule);
    } else {
        // If a custom module name was provided, we will aggregate all projects under the same module.
        modulesList.get(0).append(projectModule);
    }
}
Also used : ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) Dependency(org.jfrog.build.extractor.ci.Dependency) Module(org.jfrog.build.extractor.ci.Module)

Example 12 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class NugetRun method execute.

@Override
public BuildInfo execute() {
    BuildInfo buildInfo = null;
    try {
        prepareAndRunCmd();
        if (!StringUtils.isBlank(module)) {
            ModuleBuilder builder = new ModuleBuilder().type(ModuleType.NUGET).id(module);
            modulesList.add(builder.build());
        }
        collectDependencies();
        buildInfo = new BuildInfo();
        buildInfo.setModules(modulesList);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
    return buildInfo;
}
Also used : BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 13 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class NpmPublish method createBuild.

private BuildInfo createBuild() {
    String moduleID = StringUtils.isNotBlank(module) ? module : npmPackageInfo.toString();
    List<Artifact> artifactList = Collections.singletonList(deployedArtifact);
    Module module = new ModuleBuilder().type(ModuleType.NPM).id(moduleID).repository(repo).artifacts(artifactList).build();
    List<Module> modules = Collections.singletonList(module);
    BuildInfo buildInfo = new BuildInfo();
    buildInfo.setModules(modules);
    return buildInfo;
}
Also used : ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) Artifact(org.jfrog.build.extractor.ci.Artifact)

Example 14 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class GradleModuleExtractor method extractModule.

@Override
public Module extractModule(Project project) {
    Set<GradleDeployDetails> gradleDeployDetails = Sets.newHashSet();
    String artifactName = project.getName();
    ArtifactoryTask artifactoryTask = ProjectUtils.getBuildInfoTask(project);
    if (artifactoryTask != null) {
        artifactName = project.getName();
        try {
            artifactoryTask.collectDescriptorsAndArtifactsForUpload();
        } catch (IOException e) {
            throw new RuntimeException("Cannot collect deploy details for " + artifactoryTask.getPath(), e);
        }
        gradleDeployDetails = artifactoryTask.deployDetails;
    }
    String repo = gradleDeployDetails.stream().map(GradleDeployDetails::getDeployDetails).map(DeployDetails::getTargetRepository).findAny().orElse("");
    String moduleId = getModuleIdString(project.getGroup().toString(), artifactName, project.getVersion().toString());
    ModuleBuilder builder = new ModuleBuilder().type(ModuleType.GRADLE).id(moduleId).repository(repo);
    try {
        // Extract the module's artifacts information if a publisher exists.
        ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(project);
        if (publisher != null) {
            boolean excludeArtifactsFromBuild = publisher.isFilterExcludedArtifactsFromBuild();
            IncludeExcludePatterns patterns = new IncludeExcludePatterns(publisher.getIncludePatterns(), publisher.getExcludePatterns());
            Iterable<GradleDeployDetails> deployExcludeDetails;
            Iterable<GradleDeployDetails> deployIncludeDetails;
            if (excludeArtifactsFromBuild) {
                deployIncludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, true));
                deployExcludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, false));
            } else {
                deployIncludeDetails = Iterables.filter(gradleDeployDetails, new ProjectPredicate(project));
                deployExcludeDetails = new ArrayList<>();
            }
            builder.artifacts(calculateArtifacts(deployIncludeDetails)).excludedArtifacts(calculateArtifacts(deployExcludeDetails));
        } else {
            log.warn("No publisher config found for project: " + project.getName());
        }
        builder.dependencies(calculateDependencies(project, moduleId));
    } catch (Exception e) {
        log.error("Error during extraction: ", e);
    }
    return builder.build();
}
Also used : ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) IncludeExcludePatterns(org.jfrog.build.extractor.clientConfiguration.IncludeExcludePatterns) BuildInfoExtractorUtils.getModuleIdString(org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString) BuildInfoExtractorUtils.getTypeString(org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString) IOException(java.io.IOException) IOException(java.io.IOException) ArtifactoryTask(org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask)

Example 15 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class BuildInfoRecorder method initModule.

private void initModule(MavenProject project) {
    if (project == null) {
        logger.warn("Skipping Artifactory Build-Info module initialization: Null project.");
        return;
    }
    ModuleBuilder module = new ModuleBuilder().type(ModuleType.MAVEN);
    module.id(getModuleIdString(project.getGroupId(), project.getArtifactId(), project.getVersion()));
    module.properties(project.getProperties());
    currentModule.set(module);
    currentModuleArtifacts.set(Collections.synchronizedSet(new HashSet<>()));
    currentModuleDependencies.set(Collections.synchronizedSet(new HashSet<>()));
}
Also used : ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder)

Aggregations

ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)17 Module (org.jfrog.build.extractor.ci.Module)7 BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)6 IOException (java.io.IOException)3 BuildInfoMavenBuilder (org.jfrog.build.extractor.builder.BuildInfoMavenBuilder)3 ArrayList (java.util.ArrayList)2 BuildInfoExtractorUtils.getModuleIdString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString)2 BuildInfoExtractorUtils.getTypeString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString)2 BuildInfoBuilder (org.jfrog.build.extractor.builder.BuildInfoBuilder)2 DependencyBuilder (org.jfrog.build.extractor.builder.DependencyBuilder)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArtifactBuilder (org.jfrog.build.extractor.builder.ArtifactBuilder)1 Artifact (org.jfrog.build.extractor.ci.Artifact)1 Dependency (org.jfrog.build.extractor.ci.Dependency)1 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)1 IncludeExcludePatterns (org.jfrog.build.extractor.clientConfiguration.IncludeExcludePatterns)1 ArtifactoryManager (org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager)1 DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)1 ArtifactoryTask (org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask)1