Skip to content

Commit

Permalink
Merge 511eb07 into feb5440
Browse files Browse the repository at this point in the history
  • Loading branch information
taikuukaits committed Jun 19, 2019
2 parents feb5440 + 511eb07 commit e18bd4a
Show file tree
Hide file tree
Showing 10 changed files with 489 additions and 183 deletions.
176 changes: 0 additions & 176 deletions airgap.gradle

This file was deleted.

36 changes: 33 additions & 3 deletions build.gradle
Expand Up @@ -37,13 +37,21 @@ version = '5.6.0-SNAPSHOT'

apply plugin: 'com.blackducksoftware.integration.solution'
apply plugin: 'org.springframework.boot'
apply from: 'airgap.gradle'
apply from: 'artifactory-properties.gradle'

def createArtifactName() {
return "${buildDir}/libs/${project.name}-${version}.jar"
}

def createAirGapArtifactName() {
return "${project.name}-${version}-air-gap.zip"
}

def createAirGapArtifactLocation() {
return "${buildDir}/libs/${createAirGapArtifactName()}"
}


allprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'io.spring.dependency-management'
Expand All @@ -53,8 +61,8 @@ allprojects {
implementation "org.jetbrains.kotlin:kotlin-reflect"
implementation "com.blackducksoftware.integration:blackduck-common:${blackDuckCommonVersion}"
implementation 'com.paypal.digraph:digraph-parser:1.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9'
}
}

Expand Down Expand Up @@ -100,6 +108,7 @@ dependencies {
implementation project(":detectable")
implementation project(":detector")

implementation "org.zeroturnaround:zt-zip:1.13"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect"
implementation "com.synopsys.integration:polaris-common:${polarisCommonVersion}"
Expand Down Expand Up @@ -184,3 +193,24 @@ task verifyBlackDuckDetect() {
dependsOn verifyBlackDuckDetect
}
}

task createAirGapZip(type: JavaExec) {
dependsOn build

classpath = files(createArtifactName())
classpath += sourceSets.main.runtimeClasspath
main = 'com.synopsys.integration.detect.Application'
args = ['--detect.gradle.path=gradlew', '-z']
}

task publishAirGapZip() {
dependsOn createAirGapZip

doLast {
def airGapZipName = createAirGapArtifactName()
def airGapZipLocation = createAirGapArtifactLocation()
exec {
commandLine 'curl', '--insecure', '-u', "${project.ext.artifactoryDeployerUsername}:${project.ext.artifactoryDeployerPassword}", '-X', 'PUT', "${project.ext.artifactoryUrl}/${project.ext.artifactoryRepo}/com/synopsys/integration/${project.name}/${version}/${airGapZipName}", '-T', "${airGapZipLocation}", '-f'
}
}
}
Expand Up @@ -35,9 +35,11 @@ public class DetectArgumentState {
private final boolean isDiagnostic;
private final boolean isDiagnosticExtended;

private final boolean isGenerateAirGapZip;

public DetectArgumentState(final boolean isHelp, final boolean isHelpHtmlDocument, final boolean isHelpJsonDocument, final boolean isInteractive, final boolean isVerboseHelp, final boolean isDeprecatedHelp, final String parsedValue,
final boolean isDiagnostic,
final boolean isDiagnosticExtended) {
final boolean isDiagnosticExtended, final boolean isGenerateAirGapZip) {
this.isHelp = isHelp;
this.isHelpHtmlDocument = isHelpHtmlDocument;
this.isHelpJsonDocument = isHelpJsonDocument;
Expand All @@ -47,6 +49,7 @@ public DetectArgumentState(final boolean isHelp, final boolean isHelpHtmlDocumen
this.parsedValue = parsedValue;
this.isDiagnostic = isDiagnostic;
this.isDiagnosticExtended = isDiagnosticExtended;
this.isGenerateAirGapZip = isGenerateAirGapZip;
}

public boolean isHelp() {
Expand Down Expand Up @@ -85,4 +88,7 @@ public String getParsedValue() {
return parsedValue;
}

public boolean isGenerateAirGapZip() {
return isGenerateAirGapZip;
}
}
Expand Up @@ -40,6 +40,8 @@ public DetectArgumentState parseArgs(final ArgumentParser parser) {
final boolean isDiagnosticProvided = parser.isArgumentPresent("-d", "--diagnostic");
final boolean isDiagnosticExtendedProvided = parser.isArgumentPresent("-de", "--diagnosticExtended");

final boolean isGenerateAirGapZip = parser.isArgumentPresent("-z", "--zip");

boolean isDiagnostic = false;
boolean isDiagnosticExtended = false;

Expand All @@ -53,9 +55,11 @@ public DetectArgumentState parseArgs(final ArgumentParser parser) {
String parsedValue = null;
if (isHelp) {
parsedValue = parser.findValueForCommand("-h", "--help");
} else if (isGenerateAirGapZip) {
parsedValue = parser.findValueForCommand("-z", "--zip");
}

return new DetectArgumentState(isHelp, isHelpHtmlDocument, isHelpJsonDocument, isInteractive, isVerboseHelp, isDeprecatedHelp, parsedValue, isDiagnostic, isDiagnosticExtended);
return new DetectArgumentState(isHelp, isHelpHtmlDocument, isHelpJsonDocument, isInteractive, isVerboseHelp, isDeprecatedHelp, parsedValue, isDiagnostic, isDiagnosticExtended, isGenerateAirGapZip);
}

}
Expand Up @@ -36,6 +36,7 @@
import com.synopsys.integration.detect.DetectInfoUtility;
import com.synopsys.integration.detect.DetectableBeanConfiguration;
import com.synopsys.integration.detect.RunBeanConfiguration;
import com.synopsys.integration.detect.configuration.ConnectionManager;
import com.synopsys.integration.detect.configuration.DetectConfiguration;
import com.synopsys.integration.detect.configuration.DetectConfigurationFactory;
import com.synopsys.integration.detect.configuration.DetectConfigurationManager;
Expand Down Expand Up @@ -66,9 +67,19 @@
import com.synopsys.integration.detect.lifecycle.run.data.ProductRunData;
import com.synopsys.integration.detect.lifecycle.shutdown.ExitCodeRequest;
import com.synopsys.integration.detect.property.SpringPropertySource;
import com.synopsys.integration.detect.tool.detector.impl.DetectExecutableResolver;
import com.synopsys.integration.detect.tool.detector.inspectors.DockerInspectorInstaller;
import com.synopsys.integration.detect.tool.detector.inspectors.GradleInspectorInstaller;
import com.synopsys.integration.detect.tool.detector.inspectors.nuget.NugetInspectorInstaller;
import com.synopsys.integration.detect.util.TildeInPathResolver;
import com.synopsys.integration.detect.util.filter.DetectToolFilter;
import com.synopsys.integration.detect.workflow.ArtifactResolver;
import com.synopsys.integration.detect.workflow.DetectRun;
import com.synopsys.integration.detect.workflow.airgap.AirGapCreator;
import com.synopsys.integration.detect.workflow.airgap.AirGapPathFinder;
import com.synopsys.integration.detect.workflow.airgap.DockerAirGapCreator;
import com.synopsys.integration.detect.workflow.airgap.GradleAirGapCreator;
import com.synopsys.integration.detect.workflow.airgap.NugetAirGapCreator;
import com.synopsys.integration.detect.workflow.diagnostic.DiagnosticManager;
import com.synopsys.integration.detect.workflow.diagnostic.DiagnosticSystem;
import com.synopsys.integration.detect.workflow.diagnostic.RelevantFileTracker;
Expand All @@ -78,6 +89,13 @@
import com.synopsys.integration.detect.workflow.profiling.DetectorProfiler;
import com.synopsys.integration.detect.workflow.report.DetectConfigurationReporter;
import com.synopsys.integration.detect.workflow.report.writer.InfoLogReportWriter;
import com.synopsys.integration.detectable.detectable.executable.impl.CachedExecutableResolverOptions;
import com.synopsys.integration.detectable.detectable.executable.impl.SimpleExecutableFinder;
import com.synopsys.integration.detectable.detectable.executable.impl.SimpleExecutableResolver;
import com.synopsys.integration.detectable.detectable.executable.impl.SimpleExecutableRunner;
import com.synopsys.integration.detectable.detectable.executable.impl.SimpleLocalExecutableFinder;
import com.synopsys.integration.detectable.detectable.executable.impl.SimpleSystemExecutableFinder;
import com.synopsys.integration.detectable.detectable.file.impl.SimpleFileFinder;
import com.synopsys.integration.exception.IntegrationException;

import freemarker.template.Configuration;
Expand Down Expand Up @@ -153,6 +171,11 @@ public DetectBootResult boot(DetectRun detectRun, final String[] sourceArgs, Con

logger.info("Main boot completed. Deciding what Detect should do.");

if (detectArgumentState.isGenerateAirGapZip()) {
createAirGapZip(detectConfiguration, gson, eventSystem, configuration);
return DetectBootResult.exit(detectConfiguration);
}

final RunOptions runOptions = factory.createRunOptions();
final DetectToolFilter detectToolFilter = runOptions.getDetectToolFilter();
ProductDecider productDecider = new ProductDecider();
Expand All @@ -163,7 +186,7 @@ public DetectBootResult boot(DetectRun detectRun, final String[] sourceArgs, Con
ProductBootFactory productBootFactory = new ProductBootFactory(detectConfiguration, detectInfo, eventSystem, detectOptionManager);
ProductBoot productBoot = new ProductBoot();
ProductRunData productRunData = productBoot.boot(productDecision, detectConfiguration, new BlackDuckConnectivityChecker(), new PolarisConnectivityChecker(), productBootFactory);
if (productRunData == null){
if (productRunData == null) {
logger.info("No products to run, Detect is complete.");
return DetectBootResult.exit(detectConfiguration);
}
Expand Down Expand Up @@ -263,5 +286,25 @@ private DiagnosticManager createDiagnostics(List<DetectOption> detectOptions, De
}
}


private void createAirGapZip(DetectConfiguration detectConfiguration, Gson gson, EventSystem eventSystem, Configuration configuration) throws DetectUserFriendlyException {
ConnectionManager connectionManager = new ConnectionManager(detectConfiguration);
ArtifactResolver artifactResolver = new ArtifactResolver(connectionManager, gson);

//TODO: This is awful, why is making this so convoluted.
SimpleFileFinder fileFinder = new SimpleFileFinder();
SimpleExecutableFinder simpleExecutableFinder = SimpleExecutableFinder.forCurrentOperatingSystem(fileFinder);
SimpleLocalExecutableFinder localExecutableFinder = new SimpleLocalExecutableFinder(simpleExecutableFinder);
SimpleSystemExecutableFinder simpleSystemExecutableFinder = new SimpleSystemExecutableFinder(simpleExecutableFinder);
SimpleExecutableResolver executableResolver = new SimpleExecutableResolver(new CachedExecutableResolverOptions(false), localExecutableFinder, simpleSystemExecutableFinder);
DetectExecutableResolver detectExecutableResolver = new DetectExecutableResolver(executableResolver, detectConfiguration);
GradleInspectorInstaller gradleInspectorInstaller = new GradleInspectorInstaller(artifactResolver);
SimpleExecutableRunner simpleExecutableRunner = new SimpleExecutableRunner();
GradleAirGapCreator gradleAirGapCreator = new GradleAirGapCreator(artifactResolver, detectExecutableResolver, gradleInspectorInstaller, simpleExecutableRunner, configuration);

NugetAirGapCreator nugetAirGapCreator = new NugetAirGapCreator(new NugetInspectorInstaller(artifactResolver));
DockerAirGapCreator dockerAirGapCreator = new DockerAirGapCreator(new DockerInspectorInstaller(artifactResolver));

AirGapCreator airGapCreator = new AirGapCreator(new AirGapPathFinder(), eventSystem, gradleAirGapCreator, nugetAirGapCreator, dockerAirGapCreator);
airGapCreator.createAirGapZip();
}
}

0 comments on commit e18bd4a

Please sign in to comment.