Skip to content

Commit

Permalink
When a cpp plugin is applied, set cpp module type
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi committed Dec 23, 2023
1 parent e1eda15 commit debbd60
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import org.gradle.api.artifacts.result.ResolvedDependencyResult;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.gradle.api.plugins.PluginContainer;
import org.gradle.language.cpp.plugins.CppApplicationPlugin;
import org.gradle.language.cpp.plugins.CppLibraryPlugin;
import org.jfrog.build.api.builder.ModuleType;
import org.jfrog.build.api.util.FileChecksumCalculator;
import org.jfrog.build.extractor.ModuleExtractor;
Expand Down Expand Up @@ -79,7 +82,7 @@ private ModuleBuilder getModuleBuilder(Project project, Set<GradleDeployDetails>
.findAny()
.orElse("");
ModuleBuilder builder = new ModuleBuilder()
.type(ModuleType.GRADLE)
.type(getModuleType(project))
.id(moduleId)
.repository(repo);
try {
Expand All @@ -99,6 +102,21 @@ private ModuleBuilder getModuleBuilder(Project project, Set<GradleDeployDetails>
return builder;
}

/**
* Get the module type to publish.
*
* @param project - Project to extract the module type
* @return the module type.
*/
private ModuleType getModuleType(Project project) {
PluginContainer plugins = project.getPlugins();
if (!plugins.withType(CppApplicationPlugin.class).isEmpty() ||
!plugins.withType(CppLibraryPlugin.class).isEmpty()) {
return ModuleType.CPP;
}
return ModuleType.GRADLE;
}

/**
* Extract Artifacts from the given deploy details
*/
Expand Down

0 comments on commit debbd60

Please sign in to comment.