Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#854
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele-Cardosi committed Feb 7, 2024
2 parents 40d4579 + da09dab commit c810775
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ To complete this guide, you need:

* less than 15 minutes
* an IDE
* JDK 11+ installed with `JAVA_HOME` configured appropriately
* Apache Maven 3.8.6+
* JDK 17+ installed with `JAVA_HOME` configured appropriately
* Apache Maven 3.9.3+
* Docker
* link:{quarkus-guides-url}/building-native-image[GraalVM installed if you want to run in native mode]

Expand Down
6 changes: 4 additions & 2 deletions drools-quarkus-extension/drools-quarkus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
<version>999-SNAPSHOT</version>
</parent>

<name>Drools :: Quarkus Extension :: Runtime</name>
<artifactId>drools-quarkus</artifactId>
<name>Drools Quarkus - Runtime</name>
<description>Define and execute your business rules with Drools</description>
<url>https://www.drools.org/</url>

<properties>
<java.module.name>org.drools.quarkus.runtime</java.module.name>
Expand Down Expand Up @@ -124,7 +126,7 @@
<configuration>
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>
<capabilities>
<provides>org.drools.drl</provides>
<provides>org.drools</provides>
</capabilities>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
#

---
name: "Drools-DRL"
name: "Drools"
metadata:
keywords:
- "drools"
- "rules"
- "rule engine"
- "artificial intelligence"
- "DRL"
guide: "https://quarkus.io/guides/drools"
categories:
- "business-automation"
status: "stable"
4 changes: 4 additions & 0 deletions drools-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
</properties>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
Expand Down
37 changes: 30 additions & 7 deletions drools-util/src/main/java/org/drools/util/RemoveCommentsMain.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
package org.drools.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.stream.Collectors;

public class RemoveCommentsMain {

private static final Logger LOGGER = LoggerFactory.getLogger(RemoveCommentsMain.class);

public static void main(String... args) {
for (String fileName : args) {
try {
Files.write(Path.of(fileName), removeComments(fileName).getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
final String ignoreMissingFilesArgument = args[0];
final boolean ignoreMissingFiles = Boolean.parseBoolean(ignoreMissingFilesArgument);
for (int i = 0; i < args.length; i++) {
// If the ignoreMissingFiles argument is defined, skip it in this iteration.
if ((ignoreMissingFiles || "false".equalsIgnoreCase(ignoreMissingFilesArgument)) && i == 0) {
continue;
} else {
try {
final String fileName = args[i];
final String result = removeComments(fileName, ignoreMissingFiles);
if (result != null) {
Files.write(Path.of(fileName), result.getBytes());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}

static String removeComments(String fileName) {
static String removeComments(String fileName, final boolean ignoreMissingFiles) {
try (var lines = Files.lines(Path.of(fileName))) {
return lines.filter(line -> !line.startsWith("#")).collect(Collectors.joining("\n"));
} catch (IOException e) {
throw new RuntimeException(e);
// Ignore non-existant files.
if (ignoreMissingFiles && e instanceof NoSuchFileException) {
LOGGER.info("Ignoring file that doesn't exist: " + fileName);
return null;
} else {
throw new RuntimeException(e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class RemoveCommentsTest {

@Test
public void test() {
String result = RemoveCommentsMain.removeComments("src/test/resources/commented.properties");
String result = RemoveCommentsMain.removeComments("src/test/resources/commented.properties", false);
String expected = "provides-capabilities=org.drools.drl\ndeployment-artifact=org.drools\\:drools-quarkus-deployment\\:999-SNAPSHOT";
assertEquals(expected, result);
}
Expand Down

0 comments on commit c810775

Please sign in to comment.