From 727aaf94e4b20d1071f79905e734fb1218fbfca6 Mon Sep 17 00:00:00 2001 From: Paul Gerarts Date: Wed, 6 Jun 2018 15:17:25 +0200 Subject: [PATCH 1/4] Add maven-assembly-plugin for easy builds in mooc project --- pom.xml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pom.xml b/pom.xml index af5379a..bec07c0 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,29 @@ 0.1 + + maven-assembly-plugin + + TestSmellDetector + false + + + Main + + + + jar-with-dependencies + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.maven.plugins maven-compiler-plugin From d9192cab1bf9ccadb444baf46e71eaec17d461d5 Mon Sep 17 00:00:00 2001 From: Paul Gerarts Date: Wed, 6 Jun 2018 16:14:59 +0200 Subject: [PATCH 2/4] Replace hardcoded path separators with `File.separator` to make project platform agnostic --- src/main/java/testsmell/TestFile.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/testsmell/TestFile.java b/src/main/java/testsmell/TestFile.java index 90f8d03..a24ae75 100644 --- a/src/main/java/testsmell/TestFile.java +++ b/src/main/java/testsmell/TestFile.java @@ -2,6 +2,7 @@ import org.apache.commons.lang3.StringUtils; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -41,11 +42,12 @@ public void addSmell(AbstractSmell smell) { } public String getTagName(){ - return testFilePath.split("\\\\")[4]; + String[] splittud = testFilePath.split(String.format("\\%s", File.separator)); + return splittud[4]; } public String getTestFileName(){ - int lastIndex = testFilePath.lastIndexOf("\\"); + int lastIndex = testFilePath.lastIndexOf(File.separator); return testFilePath.substring(lastIndex+1,testFilePath.length()); } @@ -62,29 +64,29 @@ public String getProductionFileNameWithoutExtension(){ } public String getProductionFileName(){ - int lastIndex = productionFilePath.lastIndexOf("\\"); + int lastIndex = productionFilePath.lastIndexOf(File.separator); if(lastIndex==-1) return ""; return productionFilePath.substring(lastIndex+1,productionFilePath.length()); } public String getRelativeTestFilePath() { - String[] splitString = testFilePath.split("\\\\"); + String[] splitString = testFilePath.split(String.format("\\%s", File.separator)); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 5; i++) { - stringBuilder.append(splitString[i] + "\\"); + stringBuilder.append(splitString[i] + File.separator); } - return testFilePath.substring(stringBuilder.toString().length()).replace("\\", "/"); + return testFilePath.substring(stringBuilder.toString().length()).replace(File.separator, "/"); } public String getRelativeProductionFilePath() { if (!StringUtils.isEmpty(productionFilePath)) { - String[] splitString = productionFilePath.split("\\\\"); + String[] splitString = productionFilePath.split(String.format("\\%s", File.separator)); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 5; i++) { - stringBuilder.append(splitString[i] + "\\"); + stringBuilder.append(splitString[i] + File.separator); } - return productionFilePath.substring(stringBuilder.toString().length()).replace("\\", "/"); + return productionFilePath.substring(stringBuilder.toString().length()).replace(File.separator, "/"); } else { return ""; From b78bb8eb68e874ba8cc93a9b52aea8a3b2694faf Mon Sep 17 00:00:00 2001 From: Paul Gerarts Date: Wed, 6 Jun 2018 16:18:24 +0200 Subject: [PATCH 3/4] Remove duplicate maven-compiler-plugin --- pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pom.xml b/pom.xml index bec07c0..fb95194 100644 --- a/pom.xml +++ b/pom.xml @@ -32,14 +32,6 @@ 1.8 - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - From ea4b4e921a36df3c78bc0b4ac34e70c4c8e92ccf Mon Sep 17 00:00:00 2001 From: Paul Gerarts Date: Wed, 6 Jun 2018 16:20:33 +0200 Subject: [PATCH 4/4] Clean up debug lines --- src/main/java/testsmell/TestFile.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/testsmell/TestFile.java b/src/main/java/testsmell/TestFile.java index a24ae75..a3193bc 100644 --- a/src/main/java/testsmell/TestFile.java +++ b/src/main/java/testsmell/TestFile.java @@ -42,8 +42,7 @@ public void addSmell(AbstractSmell smell) { } public String getTagName(){ - String[] splittud = testFilePath.split(String.format("\\%s", File.separator)); - return splittud[4]; + return testFilePath.split(String.format("\\%s", File.separator))[4]; } public String getTestFileName(){