Skip to content

Commit

Permalink
style: please spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 committed Sep 3, 2024
1 parent 20da6d0 commit d898422
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 93 deletions.
15 changes: 15 additions & 0 deletions ast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.github.gumtreediff</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
136 changes: 67 additions & 69 deletions experiments/pom.xml
Original file line number Diff line number Diff line change
@@ -1,75 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.algomaster99</groupId>
<artifactId>by-the-pool</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.algomaster99</groupId>
<artifactId>by-the-pool</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>experiments</artifactId>
<artifactId>experiments</artifactId>

<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.11.0</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.11.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>main</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>dataset</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.example.Dataset</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
<execution>
<id>diffoscope</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>diffoscope</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.example.Diffoscope</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>main</id>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<finalName>dataset</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.example.Dataset</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
<execution>
<id>diffoscope</id>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<finalName>diffoscope</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.example.Diffoscope</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
</project>
10 changes: 6 additions & 4 deletions experiments/src/main/java/org/example/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@

public class Constants {
public static final Properties PROPERTIES;

static {
PROPERTIES = new Properties();
try {
//load a properties file from class path, inside static method
// load a properties file from class path, inside static method
PROPERTIES.load(Constants.class.getClassLoader().getResourceAsStream("config.properties"));
}
catch (IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
}
public static final Path ROOT = Paths.get(PROPERTIES.getProperty("ROOT")).toAbsolutePath().normalize();

public static final Path ROOT =
Paths.get(PROPERTIES.getProperty("ROOT")).toAbsolutePath().normalize();
public static final Path DIFFOSCOPE_EXECUTABLE = Paths.get(PROPERTIES.getProperty("DIFFOSCOPE_EXECUTABLE"));

public static Logger getLogger(Class<?> clazz, String logFileName) {
Expand Down
26 changes: 16 additions & 10 deletions experiments/src/main/java/org/example/Dataset.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.example;

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import static org.example.Constants.ROOT;

import java.io.FileReader;
import java.io.FileWriter;
Expand All @@ -10,19 +9,20 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.jar.JarFile;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.List;

import static org.example.Constants.ROOT;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;

public class Dataset {
private static final Path DATASET = ROOT.resolve("dataset");
private static final Logger logger = Constants.getLogger(Dataset.class, "dataset.log");
private static final Path OUTPUT = ROOT.resolve("output");

private static final List<String> RANDOM_NUMBERS;

static {
try {
RANDOM_NUMBERS = Files.readAllLines(ROOT.resolve("random_numbers.txt"));
Expand Down Expand Up @@ -62,18 +62,24 @@ public static void main(String[] args) throws IOException {
byte[] classfileBytes2 = getClassFileBytes(jar2, classfileInsideJar2);
String classfileName1 = getClassNameFromFullyQualifiedClassName(classfileInsideJar1);
String classfileName2 = getClassNameFromFullyQualifiedClassName(classfileInsideJar2);
Path outputClassfile1 = OUTPUT.resolve(String.valueOf(recordNumber)).resolve("first").resolve(classfileName1);
Path outputClassfile2 = OUTPUT.resolve(String.valueOf(recordNumber)).resolve("second").resolve(classfileName2);
Path outputClassfile1 = OUTPUT.resolve(String.valueOf(recordNumber))
.resolve("first")
.resolve(classfileName1);
Path outputClassfile2 = OUTPUT.resolve(String.valueOf(recordNumber))
.resolve("second")
.resolve(classfileName2);

Files.createDirectories(outputClassfile1.getParent());
Files.write(outputClassfile1, classfileBytes1);

Files.createDirectories(outputClassfile2.getParent());
Files.write(outputClassfile2, classfileBytes2);

f0.write(ROOT.relativize(outputClassfile1) + "," + ROOT.relativize(outputClassfile2) + System.lineSeparator());
f0.write(ROOT.relativize(outputClassfile1) + "," + ROOT.relativize(outputClassfile2)
+ System.lineSeparator());

logger.info("Record Number: " + recordNumber + " " + ROOT.relativize(outputClassfile1) + " " + ROOT.relativize(outputClassfile1));
logger.info("Record Number: " + recordNumber + " " + ROOT.relativize(outputClassfile1) + " "
+ ROOT.relativize(outputClassfile1));
}
f0.close();
}
Expand All @@ -87,4 +93,4 @@ private static byte[] getClassFileBytes(JarFile jar, String classfile) throws IO
private static String getClassNameFromFullyQualifiedClassName(String fullyQualifiedClassName) {
return fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf('/') + 1);
}
}
}
12 changes: 6 additions & 6 deletions experiments/src/main/java/org/example/Diffoscope.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.example;

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import static org.example.Constants.ROOT;

import java.io.FileReader;
import java.io.IOException;
Expand All @@ -10,8 +9,8 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static org.example.Constants.ROOT;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;

public class Diffoscope {

Expand All @@ -20,8 +19,9 @@ public static void main(String[] args) throws IOException, InterruptedException
Reader reader = new FileReader(paths.toFile());
Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(reader);


int workers = args.length > 0 ? Integer.parseInt(args[0]) : Runtime.getRuntime().availableProcessors();
int workers = args.length > 0
? Integer.parseInt(args[0])
: Runtime.getRuntime().availableProcessors();
ExecutorService pool = Executors.newFixedThreadPool(workers);

for (CSVRecord record : records) {
Expand Down
11 changes: 7 additions & 4 deletions experiments/src/main/java/org/example/DiffoscopeDiff.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package org.example;

import org.apache.commons.csv.CSVRecord;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Logger;
import org.apache.commons.csv.CSVRecord;

public class DiffoscopeDiff implements Runnable {
private static final Path DIFFOSCOPE = Constants.DIFFOSCOPE_EXECUTABLE;
Expand All @@ -24,7 +23,12 @@ public void run() {

Path diffRootDirectory = class1.getParent().getParent();

ProcessBuilder pb = new ProcessBuilder(DIFFOSCOPE.toString(), "--json", "diffoscope.json", diffRootDirectory.relativize(class1).toString(), diffRootDirectory.relativize(class2).toString());
ProcessBuilder pb = new ProcessBuilder(
DIFFOSCOPE.toString(),
"--json",
"diffoscope.json",
diffRootDirectory.relativize(class1).toString(),
diffRootDirectory.relativize(class2).toString());
pb.directory(diffRootDirectory.toFile());

String recordNumber = class1.getParent().getParent().getFileName().toString();
Expand All @@ -35,6 +39,5 @@ public void run() {
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}

}
}

0 comments on commit d898422

Please sign in to comment.