Skip to content

Commit

Permalink
#18 Write generated class list to file (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Aug 17, 2023
1 parent 9d1416f commit 3a52e1a
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 16 deletions.
2 changes: 1 addition & 1 deletion agent/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
Expand Down
1 change: 0 additions & 1 deletion agent/pk_generated_parent.pom

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<plugin>
<groupId>com.exasol</groupId>
<artifactId>project-keeper-maven-plugin</artifactId>
<version>2.9.9</version>
<version>2.9.10</version>
</plugin>
</plugins>
</build>
Expand Down
1 change: 1 addition & 0 deletions doc/changes/changelog.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions doc/changes/changes_0.2.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Java Class List Extractor 0.2.4, released 2023-08-17

Code name: Write Class List to File

## Summary

This release fixes a bug introduced #16 that caused class list files not being written to a file any more.

## Features

* #18: Fixed bug of missing class list file

## Dependency Updates

### Class List Extractor Agent

#### Plugin Dependency Updates

* Updated `com.exasol:project-keeper-maven-plugin:2.9.9` to `2.9.10`

### Class List Verifier

#### Plugin Dependency Updates

* Updated `com.exasol:project-keeper-maven-plugin:2.9.9` to `2.9.10`
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<plugin>
<groupId>com.exasol</groupId>
<artifactId>project-keeper-maven-plugin</artifactId>
<version>2.9.9</version>
<version>2.9.10</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion verifier/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
Expand Down
3 changes: 1 addition & 2 deletions verifier/pk_generated_parent.pom

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions verifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.exasol</groupId>
<artifactId>java-class-list-verifier</artifactId>
<version>0.2.3</version>
<version>0.2.4</version>
<packaging>jar</packaging>
<name>Class list verifier</name>
<description>Tool for extracting the used classes from Java UDF / Adapter Scripts.</description>
Expand Down Expand Up @@ -108,14 +108,14 @@
<plugin>
<groupId>com.exasol</groupId>
<artifactId>project-keeper-maven-plugin</artifactId>
<version>2.9.9</version>
<version>2.9.10</version>
</plugin>
</plugins>
</build>
<parent>
<artifactId>java-class-list-verifier-generated-parent</artifactId>
<groupId>com.exasol</groupId>
<version>0.2.3</version>
<version>0.2.4</version>
<relativePath>pk_generated_parent.pom</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
Expand All @@ -18,10 +19,11 @@
*/
// [impl->dsn~class-list-verifier~1]
public class ClassListVerifier {
private final List<Pattern> ignoreInDiffPattern;

private static final Logger LOGGER = Logger.getLogger(ClassListVerifier.class.getName());
private static final String CLASSES_LIST_FILE_NAME = "classes.lst";

private final List<Pattern> ignoreInDiffPattern;

/**
* Create a new instance of {@link ClassListVerifier}.
*
Expand All @@ -48,6 +50,8 @@ public void verifyClassListFile(final Collection<String> classList, final Path j
if (classListFile.isEmpty()) {
handleEmptyClassList(classList, jarFile);
} else {
final Path generatedFilePath = writeClassListToTarget(classList);
LOGGER.info(() -> "Wrote generated class list to " + generatedFilePath);
final Set<String> classesInFile = Arrays.stream(classListFile.get().split("\n")).map(String::trim)
.collect(Collectors.toSet());
if (classListsAreDifferent(classList, classesInFile)) {
Expand Down Expand Up @@ -84,7 +88,7 @@ private void handleEmptyClassList(final Collection<String> classList, final Path
}

private Path writeClassListToTarget(final Collection<String> classList) {
final Path generatedFilePath = Path.of("target/generated-" + CLASSES_LIST_FILE_NAME);
final Path generatedFilePath = Path.of("target/generated-" + CLASSES_LIST_FILE_NAME).toAbsolutePath();
try {
Files.writeString(generatedFilePath, String.join(System.lineSeparator(), classList));
return generatedFilePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ void testWithOutdatedClassList() throws IOException {
final List<String> classList = List.of("com/exasol/ExaMetadata", "com/exasol/Other");
final AssertionError exception = assertThrows(AssertionError.class,
() -> verifier.verifyClassListFile(classList, jar));
assertThat(exception.getMessage(), startsWith("E-JCLE-VF-16: Found outdated classes.lst in the jar file"));
assertAll(//
() -> assertThat(exception.getMessage(),
allOf(startsWith("E-JCLE-VF-16: Found outdated classes.lst in the jar file"))),
() -> assertGeneratedClassList(classList)//
);
}

@Test
Expand Down Expand Up @@ -82,8 +86,7 @@ void testWithMissingClassList() throws IOException {
() -> verifier.verifyClassListFile(classList, jar));
assertAll(//
() -> assertThat(exception.getMessage(),
allOf(startsWith("E-JCLE-VF-14: Could not find classes.lst in the jar file"), endsWith(
"You can fix that by copying the generated file from 'target/generated-classes.lst' to 'src/main/resources/classes.lst':\ncp target/generated-classes.lst src/main/resources/classes.lst"))),
startsWith("E-JCLE-VF-14: Could not find classes.lst in the jar file")),
() -> assertGeneratedClassList(classList)//
);
}
Expand Down

0 comments on commit 3a52e1a

Please sign in to comment.