Skip to content

Commit

Permalink
feat: add --no-integrations option
Browse files Browse the repository at this point in the history
  • Loading branch information
maxandersen authored and quintesse committed Dec 2, 2024
1 parent ae55c05 commit b3abe6e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/java/dev/jbang/cli/BuildMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import java.util.List;
import java.util.Map;

import dev.jbang.util.Util;

import picocli.CommandLine;
import picocli.CommandLine.Option;

public class BuildMixin {
public String javaVersion;
Expand Down Expand Up @@ -33,6 +36,12 @@ void setJavaVersion(String javaVersion) {
@CommandLine.Option(names = { "--manifest" }, parameterConsumer = KeyValueConsumer.class)
public Map<String, String> manifestOptions;

@Option(names = {
"--integrations" }, description = "Enable integration execution (default: true)", negatable = true)
void setIntegrations(boolean enabled) {
Util.setIntegrationsEnabled(enabled);
}

public List<String> opts() {
List<String> opts = new ArrayList<>();
if (javaVersion != null) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/dev/jbang/source/AppBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public CmdGeneratorBuilder build() throws IOException {
// do the actual building
try {
getCompileBuildStep().build();
integrationResult = getIntegrationBuildStep().build();

if (!Util.isIntegrationsEnabled()) {
integrationResult = getIntegrationBuildStep().build();
}

getJarBuildStep().build();
} finally {
if (!keepClasses()) {
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/dev/jbang/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class Util {
Pattern.MULTILINE);

public static final Pattern mainClassMethod = Pattern.compile(
"(?<=\\n|\\A)(?:public\\s)\\s*(class)\\s*([^\\n\\s]*)");
"(?<=\n|\\A)(?:public\\s)\\s*(class)\\s*([^\\n\\s]*)");

public static final Pattern patternFQCN = Pattern.compile(
"^([a-z][a-z0-9]*\\.)*[a-zA-Z][a-zA-Z0-9_]*$");
Expand All @@ -99,6 +99,8 @@ public class Util {
private static Boolean downloadSources;
private static Instant startTime = Instant.now();

private static boolean integrationsEnabled = true;

public static void setVerbose(boolean verbose) {
Util.verbose = verbose;
if (verbose) {
Expand Down Expand Up @@ -1954,4 +1956,12 @@ public static String substituteRemote(String arg) {
public static <K, V> Entry<K, V> entry(K k, V v) {
return new AbstractMap.SimpleEntry<K, V>(k, v);
}

public static void setIntegrationsEnabled(boolean enabled) {
Util.integrationsEnabled = enabled;
}

public static boolean isIntegrationsEnabled() {
return integrationsEnabled;
}
}

0 comments on commit b3abe6e

Please sign in to comment.