Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (2)
......@@ -3,5 +3,5 @@
.classpath
.project
*.class
.idea/
\ No newline at end of file
/examples/
.idea/
......@@ -23,6 +23,9 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class CopyTests {
static {
System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT %4$s %2$s: %5$s%6$s%n");
}
private static Logger log = java.util.logging.Logger.getLogger(CopyTests.class.getName());
public static final List<String> skipNames = List.of("target", ".settings", ".project", ".classpath");
......
......@@ -20,7 +20,9 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class Download {
static {
System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT %4$s %2$s: %5$s%6$s%n");
}
private static Logger log = java.util.logging.Logger.getLogger(Download.class.getName());
public static final List<String> skipNames = List.of("target", ".settings", ".project", ".classpath");
public static final String TAR_GZ_PATTERN = ".*\\.tar\\.gz";
......
......@@ -57,7 +57,9 @@ import org.w3c.dom.Node;
import org.xml.sax.SAXException;
public class FixDirStructure {
static {
System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT %4$s %2$s: %5$s%6$s%n");
}
private static Logger log = java.util.logging.Logger.getLogger(FixDirStructure.class.getName());
public static final List<String> skipNames = List.of("target", ".settings", ".project", ".classpath",
".kelvin-utils");
......@@ -96,6 +98,7 @@ public class FixDirStructure {
.filter(f -> !"result.html".equals(f.getName())).toList();
boolean pomExist = files.stream().anyMatch(f -> f.getName().equals("pom.xml"));
long multiPomCount = findFiles(dir, "pom.xml").size();
findFiles(dir, "pom.xml").stream().forEach(f -> System.out.println(f));
long multiPomCountInRootDir = files.stream()
.filter(f -> !f.isDirectory() && f.getName().matches("pom(\\s*\\((.*)\\))?\\.xml")).count();
boolean onlyJava = files.stream().filter(f -> !f.getName().equals("pom.xml"))
......@@ -106,9 +109,13 @@ public class FixDirStructure {
&& files.stream().filter(f -> !f.getName().equals("pom.xml"))
.allMatch(f -> f.getName().toLowerCase().matches("src|src.zip"));
boolean onlyTarGz = files.size() == 1 && files.stream().allMatch(f -> f.getName().matches(TAR_GZ_PATTERN));
System.out.println("multiPomCount " + multiPomCountInRootDir);
System.out.printf("pomExist: %b onlyJava: %b onlyOnedir: %b pomAndSrcZip:%b onlyTarGz:%b", pomExist, onlyJava,
onlyOneDir, pomAndSrcZip, onlyTarGz);
log.info(()-> "multi Pom Count :" + multiPomCount);
log.info(()-> "multi Pom Count in root :" + multiPomCountInRootDir);
log.info(() -> "pom Exist : " + pomExist);
log.info(() -> "only Java : " + onlyJava);
log.info(() -> "only One Dir : " + onlyOneDir);
log.info(() -> "pom And Src Zip: " + pomAndSrcZip);
log.info(() -> "only Tar Gz : " + onlyTarGz);
log.info("");
log.info("");
if (onlyTarGz) {
......@@ -328,9 +335,9 @@ public class FixDirStructure {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(pom.toFile());
ifNotExistAddLib(doc, "junit-jupiter-api", "org.junit.jupiter", "5.11.0", "test",true);
ifNotExistAddLib(doc, "junit-jupiter-engine", "org.junit.jupiter", "5.11.0", "test",true);
ifNotExistAddLib(doc, "junit-jupiter-params", "org.junit.jupiter", "5.11.0", "test",true);
ifNotExistAddLib(doc, "junit-jupiter-api", "org.junit.jupiter", "5.11.0", "test", true);
ifNotExistAddLib(doc, "junit-jupiter-engine", "org.junit.jupiter", "5.11.0", "test", true);
ifNotExistAddLib(doc, "junit-jupiter-params", "org.junit.jupiter", "5.11.0", "test", true);
ifNotExistAddLib(doc, "kelvin-java-unittest-support", "cz.vsb.fei", "[0.0.2,)", "test", false);
ifNotExistAddRep(doc, "vsb-education-release",
"https://artifactory.cs.vsb.cz/repository/education-releases/");
......@@ -350,9 +357,9 @@ public class FixDirStructure {
}
}
private static void ifNotExistAddLib(Document doc, String artifactId, String groupId, String version, String scope, boolean force)
throws XPathExpressionException {
if(force) {
private static void ifNotExistAddLib(Document doc, String artifactId, String groupId, String version, String scope,
boolean force) throws XPathExpressionException {
if (force) {
removeIfExist(doc, "/project/dependencies/dependency/artifactId[text() = '" + artifactId + "']", true);
}
XPath xPath = XPathFactory.newInstance().newXPath();
......@@ -377,7 +384,7 @@ public class FixDirStructure {
private static void removeIfExist(Document doc, String xpathQuery, boolean parent) throws XPathExpressionException {
XPath xPath = XPathFactory.newInstance().newXPath();
Node result = (Node) xPath.compile(xpathQuery).evaluate(doc, XPathConstants.NODE);
if(result != null && parent) {
if (result != null && parent) {
result = result.getParentNode();
}
if (result != null) {
......