Skip to content

Intermediate version #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ out
.settings

# NetBeans
.nbattrs
.nbattrs
/log.txt
116 changes: 57 additions & 59 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@
<?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>
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>

<groupId>org.quickperf</groupId>
<artifactId>maven-test-bench</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>org.quickperf</groupId>
<artifactId>maven-test-bench</artifactId>
<version>1.0-SNAPSHOT</version>

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

<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.quickperf</groupId>
<artifactId>quick-perf-junit4</artifactId>
<version>1.0.0-RC4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<!-- To avoid "SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
with oshi-core
-->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.quickperf</groupId>
<artifactId>quick-perf-junit4</artifactId>
<version>1.0.0-RC4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.28</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
35 changes: 34 additions & 1 deletion src/main/java/BenchProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ private BenchProperties() {
private String mavenBinariesPath;

private String projectUnderTest;

private String commitFirstHash;

private String commitLastHash;

private String mavenSourceBranch;

private List<Maven3Version> maven3VersionsToMeasure;
private String mavenSourcePath;

private List<Maven3Version> maven3VersionsToMeasure;

private void initializeProperties() {
try {
Expand All @@ -45,6 +53,14 @@ private void initializeProperties() {
this.exportPathOfMeasures = properties.getProperty("measures.export.path");

this.maven3VersionsToMeasure = findMaven3VersionsToMeasure(properties);

this.commitFirstHash=properties.getProperty("commit.first.hash");

this.commitLastHash=properties.getProperty("commit.last.hash");

this.mavenSourcePath = properties.getProperty("maven.sources.path");

this.mavenSourceBranch=properties.getProperty("maven.sources.branch","master");

} catch (IOException e) {
throw new IllegalStateException("Unable to load bench properties.", e);
Expand Down Expand Up @@ -124,5 +140,22 @@ public String getPathOfProjectUnderTest() {
public List<Maven3Version> getMaven3VersionsToMeasure() {
return maven3VersionsToMeasure;
}

public String getCommitFirstHash() {
return commitFirstHash;
}

public String getCommitLastHash() {
return commitLastHash;
}

public String getMavenSourceBranch() {
return mavenSourceBranch;
}


public String getMavenSourcePath() {
return mavenSourcePath;
}

}
4 changes: 4 additions & 0 deletions src/main/java/CmdExecutionResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

public class CmdExecutionResult {

}
111 changes: 111 additions & 0 deletions src/main/java/GitDelegate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import java.io.IOException;
import java.io.StringWriter;
import java.nio.file.Path;

import org.apache.commons.io.IOUtils;

public class GitDelegate {

private final static String repoUrl = "https://github.com/apache/maven.git";

public static void clone(Path path) {
try {
System.out.println("Cloning "+repoUrl+" into "+path.toAbsolutePath());
ProcessBuilder pb = new ProcessBuilder("git","clone",repoUrl);
pb.directory(path.toFile());
Process process = pb.start();

final StringWriter messageWriter = new StringWriter();
final StringWriter errorWriter = new StringWriter();

Thread outDrainer = new Thread(new Runnable() {
public void run() {
try {
IOUtils.copy(process.getInputStream(), messageWriter);
} catch (IOException e) {
}
}
});

Thread errorDrainer = new Thread(new Runnable() {
public void run() {
try {
IOUtils.copy(process.getErrorStream(), errorWriter);
} catch (IOException e) {
}
}
});

outDrainer.start();
errorDrainer.start();

int err = process.waitFor();

outDrainer.join();
errorDrainer.join();

if (err != 0) {
throw new RuntimeException("Error during repository clone "+errorWriter.toString());
}

String message = messageWriter.toString();
System.out.println("Cloning completed "+message);
} catch (IOException | InterruptedException ex) {
throw new RuntimeException("Error during repository clone "+ex.getMessage());
}

}

public static void checkOut(Path path,String branch, String commitHash) {
try {
System.out.println("checkout branch "+branch+ " commit hash "+commitHash);
ProcessBuilder pb = new ProcessBuilder("git","checkout",commitHash);
pb.directory(path.toFile());
Process process = pb.start();

final StringWriter messageWriter = new StringWriter();
final StringWriter errorWriter = new StringWriter();

Thread outDrainer = new Thread(new Runnable() {
public void run() {
try {
IOUtils.copy(process.getInputStream(), messageWriter);
} catch (IOException e) {
}
}
});

Thread errorDrainer = new Thread(new Runnable() {
public void run() {
try {
IOUtils.copy(process.getErrorStream(), errorWriter);
} catch (IOException e) {
}
}
});

outDrainer.start();
errorDrainer.start();

int err = process.waitFor();

outDrainer.join();
errorDrainer.join();

if (err != 0) {
String errorMessage = errorWriter.toString();
System.out.println("Errror message: "+errorMessage);
return ;
}

String message = messageWriter.toString();
System.out.println("Completed Cloning "+message);

} catch (IOException | InterruptedException ex) {
System.out.println("Errror message "+ex.getMessage());
}
}



}
1 change: 1 addition & 0 deletions src/main/java/Maven3Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum Maven3Version {
,V_3_6_1("3.6.1")
,V_3_6_2("3.6.2")
,HEAD("head")
,HASH("hash")
;

private final String numVersion;
Expand Down
Loading