diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
index d03e88f1..ebd6bc6d 100644
--- a/.github/copilot-instructions.md
+++ b/.github/copilot-instructions.md
@@ -5,7 +5,7 @@
This repository contains 24 Java libraries developed by the SPeCS research group, organized as independent Gradle projects. Each library extends or enhances existing Java libraries (indicated by the "-Plus" suffix) or provides custom utilities. The repository uses Java 17, Gradle for builds, and follows a multi-project structure without a root Gradle configuration.
**Repository Statistics:**
-- 24 main Java libraries + 3 legacy projects (RuntimeMutators, SpecsHWUtils, SupportJavaLibs)
+- 24 main Java libraries + 1 legacy project (SpecsHWUtils)
- ~200K+ lines of Java code across all projects
- Mixed testing frameworks: JUnit 5 (modern projects) and JUnit 4 (legacy projects)
- Inter-project dependencies centered around SpecsUtils as the core utility library
@@ -101,13 +101,10 @@ ProjectName/
**Development Tools:**
- **JavaGenerator** - Java code generation utilities
-- **EclipseUtils** - Eclipse IDE integration tools
- **AntTasks** - Custom Ant build tasks
### Legacy Projects (No Gradle builds)
-- **RuntimeMutators** - Runtime code mutation (Eclipse project only)
- **SpecsHWUtils** - Hardware utilities (Eclipse project only)
-- **SupportJavaLibs** - Supporting libraries and tools
## Continuous Integration
@@ -125,7 +122,7 @@ File: `.github/workflows/nightly.yml`
5. Generates dependency graphs
### Tested Projects (in CI order):
-AntTasks, AsmParser, CommonsCompressPlus, CommonsLangPlus, GearmanPlus, GitlabPlus, GitPlus, Gprofer, GsonPlus, GuiHelper, JacksonPlus, JadxPlus, JavaGenerator, jOptions, JsEngine, LogbackPlus, MvelPlus, SlackPlus, SpecsUtils, SymjaPlus, tdrcLibrary, XStreamPlus, Z3Helper
+AntTasks, AsmParser, CommonsCompressPlus, CommonsLangPlus, GearmanPlus, GitlabPlus, GitPlus, Gprofer, GsonPlus, GuiHelper, JacksonPlus, JadxPlus, JavaGenerator, jOptions, JsEngine, LogbackPlus, MvelPlus, SlackPlus, SpecsUtils, SymjaPlus, tdrcLibrary, XStreamPlus
### Local Validation Steps
1. **Build specific project**: `cd ProjectName && gradle build`
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 25e0cf68..f6064405 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -41,7 +41,6 @@ jobs:
AsmParser
CommonsCompressPlus
CommonsLangPlus
- GearmanPlus
GitlabPlus
GitPlus
Gprofer
@@ -59,13 +58,12 @@ jobs:
SymjaPlus
tdrcLibrary
XStreamPlus
- Z3Helper
)
failed=()
for project in "${projects[@]}"; do
echo "\n===== Building and testing $project ====="
cd "$project"
- if ! gradle build test; then
+ if ! gradle build; then
echo "[ERROR] $project failed to build or test"
failed+=("$project")
fi
diff --git a/AntTasks/build.gradle b/AntTasks/build.gradle
index fea624c7..fcfe2501 100644
--- a/AntTasks/build.gradle
+++ b/AntTasks/build.gradle
@@ -22,11 +22,11 @@ dependencies {
implementation ':SpecsUtils'
// Ivy dependencies
- implementation group: 'org.apache.ant', name: 'ant', version: '1.9.1'
- implementation group: 'org.apache.ivy', name: 'ivy', version: '2.5.0-rc1'
- implementation group: 'org.apache.ant', name: 'ant-jsch', version: '1.10.5'
- implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
- implementation group: 'com.io7m.xom', name: 'xom', version: '1.2.10'
+ implementation 'org.apache.ant:ant:1.9.1'
+ implementation 'org.apache.ivy:ivy:2.5.0-rc1'
+ implementation 'org.apache.ant:ant-jsch:1.10.5'
+ implementation 'org.slf4j:slf4j-simple:1.7.25'
+ implementation 'com.io7m.xom:xom:1.2.10'
}
// Project sources
diff --git a/AntTasks/settings.gradle b/AntTasks/settings.gradle
index 3d0a1fd3..fd458edf 100644
--- a/AntTasks/settings.gradle
+++ b/AntTasks/settings.gradle
@@ -1,4 +1,4 @@
rootProject.name = 'AntTasks'
-includeBuild("../../specs-java-libs/jOptions")
-includeBuild("../../specs-java-libs/SpecsUtils")
+includeBuild("../jOptions")
+includeBuild("../SpecsUtils")
diff --git a/AsmParser/build.gradle b/AsmParser/build.gradle
index 4271b9f9..1f48c8a3 100644
--- a/AsmParser/build.gradle
+++ b/AsmParser/build.gradle
@@ -1,54 +1,45 @@
plugins {
- id 'distribution'
+ id 'distribution'
+ id 'java'
}
-// Java project
-apply plugin: 'java'
-
java {
+ withSourcesJar()
+
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
-
// Repositories providers
repositories {
mavenCentral()
}
dependencies {
- testImplementation "junit:junit:4.13.1"
-
+ testImplementation "junit:junit:4.13.1"
+
implementation ':SpecsUtils'
implementation ':jOptions'
- implementation group: 'com.google.code.gson', name: 'gson', version: '2.12.1'
+ implementation 'com.google.code.gson:gson:2.12.1'
}
-java {
- withSourcesJar()
-}
-
-
// Project sources
sourceSets {
- main {
- java {
- srcDir 'src'
- }
-
- resources {
- srcDir 'test'
- }
- }
-
- test {
- java {
- srcDir 'test'
- }
-
- resources {
- srcDir 'test'
- }
- }
+ main {
+ java {
+ srcDir 'src'
+ }
+ resources {
+ srcDir 'resources'
+ }
+ }
+ test {
+ java {
+ srcDir 'test'
+ }
+ resources {
+ srcDir 'test'
+ }
+ }
}
diff --git a/AsmParser/settings.gradle b/AsmParser/settings.gradle
index f70e545c..4c233b5d 100644
--- a/AsmParser/settings.gradle
+++ b/AsmParser/settings.gradle
@@ -1,4 +1,4 @@
rootProject.name = 'AsmParser'
-includeBuild("../../specs-java-libs/SpecsUtils")
-includeBuild("../../specs-java-libs/jOptions")
\ No newline at end of file
+includeBuild("../SpecsUtils")
+includeBuild("../jOptions")
diff --git a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmFieldData.java b/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmFieldData.java
index 5856d57d..1b2cab48 100644
--- a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmFieldData.java
+++ b/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmFieldData.java
@@ -15,13 +15,12 @@
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Objects;
import org.suikasoft.jOptions.DataStore.ADataClass;
import org.suikasoft.jOptions.Datakey.DataKey;
import org.suikasoft.jOptions.Datakey.KeyFactory;
-import pt.up.fe.specs.util.SpecsCheck;
-
/**
* Raw field data as extracted by an {@link IsaParser}
*
@@ -98,7 +97,7 @@ public int getReducedOpcode() {
public int getFieldAsBinaryInteger(String fieldName) {
var valueString = get(AsmFieldData.FIELDS).get(fieldName);
- SpecsCheck.checkNotNull(valueString, () -> "No value found for field " + fieldName);
+ Objects.requireNonNull(valueString, () -> "No value found for field " + fieldName);
return Integer.parseInt(valueString, 2);
}
diff --git a/CommonsCompressPlus/build.gradle b/CommonsCompressPlus/build.gradle
index 21001218..8170ad96 100644
--- a/CommonsCompressPlus/build.gradle
+++ b/CommonsCompressPlus/build.gradle
@@ -1,38 +1,31 @@
plugins {
- id 'distribution'
+ id 'distribution'
+ id 'java'
}
-// Java project
-apply plugin: 'java'
-
java {
+ withSourcesJar()
+
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
-
// Repositories providers
repositories {
mavenCentral()
}
dependencies {
- testImplementation "junit:junit:4.13.1"
-
- implementation ':SpecsUtils'
+ implementation ':SpecsUtils'
- implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.27.1'
-}
-
-java {
- withSourcesJar()
+ implementation 'org.apache.commons:commons-compress:1.27.1'
}
// Project sources
sourceSets {
- main {
- java {
- srcDir 'src'
- }
- }
+ main {
+ java {
+ srcDir 'src'
+ }
+ }
}
diff --git a/CommonsCompressPlus/settings.gradle b/CommonsCompressPlus/settings.gradle
index 1323782e..15d5a0e8 100644
--- a/CommonsCompressPlus/settings.gradle
+++ b/CommonsCompressPlus/settings.gradle
@@ -1,3 +1,3 @@
rootProject.name = 'CommonsCompressPlus'
-includeBuild("../../specs-java-libs/SpecsUtils")
\ No newline at end of file
+includeBuild("../SpecsUtils")
diff --git a/CommonsLangPlus/build.gradle b/CommonsLangPlus/build.gradle
index c093f816..f247cd87 100644
--- a/CommonsLangPlus/build.gradle
+++ b/CommonsLangPlus/build.gradle
@@ -17,23 +17,16 @@ repositories {
}
dependencies {
- implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
- implementation group: 'org.apache.commons', name: 'commons-text', version: '1.13.0'
+ implementation 'org.apache.commons:commons-lang3:3.18.0'
+ implementation 'org.apache.commons:commons-text:1.13.0'
// Testing dependencies
- testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.10.0'
- testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.5.0'
- testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '5.5.0'
- testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.24.2'
- testImplementation group: 'org.mockito', name: 'mockito-inline', version: '5.2.0' // For static mocking
- testRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-launcher'
-}
-
-java {
- withSourcesJar()
-
- sourceCompatibility = JavaVersion.VERSION_17
- targetCompatibility = JavaVersion.VERSION_17
+ testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
+ testImplementation 'org.mockito:mockito-core:5.5.0'
+ testImplementation 'org.mockito:mockito-junit-jupiter:5.5.0'
+ testImplementation 'org.assertj:assertj-core:3.24.2'
+ testImplementation 'org.mockito:mockito-inline:5.2.0' // For static mocking
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.0'
}
// Project sources
diff --git a/CommonsLangPlus/src/pt/up/fe/specs/lang/SpecsPlatforms.java b/CommonsLangPlus/src/pt/up/fe/specs/lang/SpecsPlatforms.java
index a0e04100..2cb147f0 100644
--- a/CommonsLangPlus/src/pt/up/fe/specs/lang/SpecsPlatforms.java
+++ b/CommonsLangPlus/src/pt/up/fe/specs/lang/SpecsPlatforms.java
@@ -16,7 +16,8 @@
import org.apache.commons.lang3.SystemUtils;
/**
- * Utility class providing wrappers around Apache commons-lang methods for system platform identification.
+ * Utility class providing wrappers around Apache commons-lang methods for
+ * system platform identification.
*
* Includes methods to check the current operating system and platform details.
*
@@ -50,7 +51,7 @@ public static boolean isLinux() {
* @return true if Linux ARM, false otherwise
*/
public static boolean isLinuxArm() {
- return SystemUtils.IS_OS_LINUX && "arm".equals(System.getProperty("os.arch").toLowerCase());
+ return SystemUtils.IS_OS_LINUX && "arm".equalsIgnoreCase(System.getProperty("os.arch"));
}
/**
diff --git a/EclipseUtils/.gitignore b/EclipseUtils/.gitignore
deleted file mode 100644
index 6fdf4f43..00000000
--- a/EclipseUtils/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build
-jar-in-jar-loader.zip
diff --git a/EclipseUtils/PsfBuilder-run.launch b/EclipseUtils/PsfBuilder-run.launch
deleted file mode 100644
index 658372ff..00000000
--- a/EclipseUtils/PsfBuilder-run.launch
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/build.gradle b/EclipseUtils/build.gradle
deleted file mode 100644
index c130661d..00000000
--- a/EclipseUtils/build.gradle
+++ /dev/null
@@ -1,56 +0,0 @@
-plugins {
- id 'distribution'
- id 'java'
-}
-
-java {
- withSourcesJar()
-
- sourceCompatibility = JavaVersion.VERSION_17
- targetCompatibility = JavaVersion.VERSION_17
-}
-
-// Repositories providers
-repositories {
- mavenCentral()
-}
-
-dependencies {
- testImplementation "junit:junit:4.13.1"
-
- implementation ':CommonsLangPlus'
- implementation ':GuiHelper'
- implementation ':SpecsUtils'
- implementation ':XStreamPlus'
- implementation ':jOptions'
-
- implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '6.6.0.202305301015-r'
- implementation group: 'com.google.guava', name: 'guava', version: '19.0'
- implementation group: 'org.apache.ant', name: 'ant-jsch', version: '1.10.13'
- implementation group: 'org.apache.ivy', name: 'ivy', version: '2.5.1'
- implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
- implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
-}
-
-// Project sources
-sourceSets {
- main {
- java {
- srcDir 'src'
- srcDir 'src-psfbuilder'
- srcDir 'builds'
- }
- resources {
- srcDir 'resources'
- }
- }
-
- test {
- java {
- srcDir 'test'
- }
- resources {
- srcDir 'resources'
- }
- }
-}
diff --git a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/BuildResource.java b/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/BuildResource.java
deleted file mode 100644
index 3f46ba2e..00000000
--- a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/BuildResource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.builder;
-
-import pt.up.fe.specs.util.providers.ResourceProvider;
-
-/**
- * @author Joao Bispo
- *
- */
-public enum BuildResource implements ResourceProvider {
-
- RESOLVE_TEMPLATE("resolve.xml.template"),
- JARFOLDER_TEMPLATE("jarfolder.template"),
- COMPILE_TEMPLATE("compile.xml.template"),
- COPY_TEMPLATE("copy.xml.template"),
- DELETE_TEMPLATE("delete.xml.template"),
- JUNIT_TEMPLATE("junit.xml.template"),
- BENCHMARKER_TEMPLATE("run.benchmarker.template"),
- MAIN_TEMPLATE("main.xml.template"),
- JUNIT("junit.jar"),
- HAMCREST("hamcrest.core.jar");
-
- private final static String RESOURCE_FOLDER = "build";
-
- private final String resource;
-
- private BuildResource(String resource) {
- this.resource = BuildResource.RESOURCE_FOLDER + "/" + resource;
- }
-
- /* (non-Javadoc)
- * @see pt.up.fe.specs.util.Interfaces.ResourceProvider#getResource()
- */
- @Override
- public String getResource() {
- return resource;
- }
-
-}
diff --git a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/BuildUtils.java b/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/BuildUtils.java
deleted file mode 100644
index 43199997..00000000
--- a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/BuildUtils.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/**
- * Copyright 2014 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.builder;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import com.google.common.base.Preconditions;
-
-import pt.up.fe.specs.eclipse.Classpath.ClasspathFiles;
-import pt.up.fe.specs.eclipse.Classpath.ClasspathParser;
-import pt.up.fe.specs.eclipse.Utilities.DeployUtils;
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.parsing.arguments.ArgumentsParser;
-import pt.up.fe.specs.util.utilities.LineStream;
-import pt.up.fe.specs.util.utilities.Replacer;
-
-public class BuildUtils {
-
- private static final String REPORTS_FOLDERNAME = "reports-eclipse-build";
-
- // private static final String RESOURCES_FOLDER = "resources";
-
- /**
- * The target name, which is "build_".
- *
- * @return
- */
- public static String getCompileTargetName(String projectName) {
- return "compile_" + projectName;
- }
-
- /**
- * A list with the name of the dependencies of the project.
- *
- * @param classpathFiles
- * @return
- */
- public static String getDependencies(ClasspathFiles classpathFiles) {
-
- StringBuilder builder = new StringBuilder();
-
- // String dependencies = getDependenciesPrivate(classpathFiles.getDependentProjects(), true);
- builder.append(getDependenciesPrivate(classpathFiles.getDependentProjects(), true));
-
- if (classpathFiles.getIvyPath().isPresent()) {
- // Add comma, if not empty
- if (builder.length() != 0) {
- builder.append(",");
- }
- // dependencies = dependencies + "," + BuildUtils.getIvyTargetName(classpathFiles.getProjectName());
- builder.append(BuildUtils.getIvyTargetName(classpathFiles.getProjectName()));
- }
-
- // if (dependencies.isEmpty()) {
- if (builder.length() == 0) {
- // return dependencies;
- return "";
- }
-
- // return "depends=\"" + dependencies + "\"";
- return "depends=\"" + builder.toString() + "\"";
- }
-
- public static String getIvyTargetName(String projectName) {
- return "resolve_" + projectName;
- }
-
- public static String getDependenciesSuffix(List projects) {
- return getDependenciesPrivate(projects, false);
- }
-
- private static String getDependenciesPrivate(List projects, boolean firstDependencies) {
-
- if (projects.isEmpty()) {
- return "";
- }
-
- StringBuilder builder = new StringBuilder();
-
- // builder.append("depends=\"");
-
- // Append first
- if (!firstDependencies) {
- builder.append(",");
- }
- builder.append(getCompileTargetName(projects.get(0)));
- // Append remaining
- for (int i = 1; i < projects.size(); i++) {
- // for (String project : projects) {
- builder.append(",");
- builder.append(getCompileTargetName(projects.get(i)));
- // builder.append(getCompileTargetName(project));
- }
- // builder.append("\"");
-
- return builder.toString();
- }
-
- /**
- * A list with the name of the junit dependencies of the project, without "depends", just the name of the targets.
- *
- * @param projects
- * @return
- */
- public static String getJUnitTargetDependencies(Collection projects) {
- return getJUnitTargetDependencies(projects, false);
- }
-
- /**
- *
- * @param projects
- * @param isFirst
- * must be true if the target dependencies are the first elements of the property where they will be
- * used.
- * @return
- */
- public static String getJUnitTargetDependencies(Collection projects, boolean isFirst) {
-
- if (projects.isEmpty()) {
- return "";
- }
-
- StringBuilder builder = new StringBuilder();
-
- boolean skipFirstComma = isFirst;
-
- // Append all (there is already a "depends" of the junit target)
- for (String projectName : projects) {
- // for (int i = 0; i < projects.size(); i++) {
- if (skipFirstComma) {
- skipFirstComma = false;
- } else {
- builder.append(",");
- }
-
- builder.append(getJUnitTargetName(projectName));
- }
-
- return builder.toString();
- }
-
- public static File getOutputJar(String projectName) {
- File outputFolder = getOutputJarFolder();
- return new File(outputFolder, projectName + ".jar");
- }
-
- private static File getOutputJarFolder() {
- return SpecsIo.mkdir("./jars");
- }
-
- // public static String buildFileset(String projectName, ClasspathParser parser) {
- public static String buildFileset(String projectName, ClasspathParser parser) {
-
- ClasspathFiles classpathFiles = parser.getClasspath(projectName);
-
- final String prefix = " ";
- StringBuilder fileset = new StringBuilder();
-
- // Add JAR files
- for (File jarFile : classpathFiles.getJarFiles()) {
- String line = DeployUtils.getZipfileset(jarFile);
-
- fileset.append(prefix);
- fileset.append(line);
- fileset.append("\n");
- }
-
- // Add self jar and parent projects JARs
- // List projects = new ArrayList<>();
- // projects.add(classpathFiles.getProjectName());
- // projects.addAll(classpathFiles.getParentProjects());
-
- for (String parent : classpathFiles.getDependentProjects()) {
- // Get project jar
- // File jarFile = getOutputJar(parent);
- // String line = DeployUtils.getZipfileset(jarFile);
- String line = DeployUtils.getPathElement(new File(getBinFoldername(parser.getClasspath(parent))));
-
- fileset.append(prefix);
- fileset.append(line);
- fileset.append("\n");
- }
-
- // If classpath has an ivy path, add Ivy jar folder
- if (classpathFiles.getIvyPath().isPresent()) {
- File projectFolder = classpathFiles.getProjectFolder();
- fileset.append(getIvyFileset(projectFolder)).append("\n");
- }
-
- // Add Ivy jar folders of other projects
- for (String project : classpathFiles.getProjectsWithIvy()) {
- ClasspathFiles projectFiles = parser.getClasspath(project);
- assert projectFiles.getIvyPath().isPresent() : "Needs to have an Ivy definition";
- File projectFolder = projectFiles.getProjectFolder();
- fileset.append(getIvyFileset(projectFolder)).append("\n");
- // System.out.println("ADDING IVY JARS of '" + project + "' to '" + classpathFiles.getProjectName() + "'");
- }
-
- return fileset.toString();
- }
-
- private static String getIvyFileset(File projectNameWithIvy) {
- String ivyJarFolder = BuildUtils.getIvyJarFoldername(projectNameWithIvy);
- Replacer ivyFileset = new Replacer(BuildResource.JARFOLDER_TEMPLATE);
- ivyFileset.replace("", ivyJarFolder);
- String ivyFilesetString = ivyFileset.toString();
- return ivyFilesetString;
- }
-
- public static String getIvyJarFoldername(File projectFolder) {
- // return new File(projectFolder, "ivy").getAbsolutePath();
- return getIvyJarFolder(projectFolder).getAbsolutePath();
- }
-
- public static File getIvyJarFolder(File projectFolder) {
- return new File(projectFolder, "ivy");
- }
-
- /**
- * Returns /bin
- *
- * @param classpathFiles
- * @return
- */
- public static String getBinFoldername(ClasspathFiles classpathFiles) {
- // File binFolder = IoUtils.safeFolder(classpathFiles.getProjectFolder(), "bin");
- // return binFolder.getAbsolutePath();
- return getBinFolder(classpathFiles.getProjectFolder()).getAbsolutePath();
- }
-
- public static File getBinFolder(File projectFolder) {
- return SpecsIo.mkdir(projectFolder, "bin");
- }
-
- /**
- *
- * @param ignoreTestFolders
- * if true, ignores folders that end with '-test'
- */
- public static String getSourcePath(ClasspathFiles classpathFiles, boolean ignoreTestFolders) {
- StringBuilder builder = new StringBuilder();
-
- String sourceTemplate = "\"/>";
-
- for (String source : classpathFiles.getSourceFolders()) {
- File sourceFolder = new File(classpathFiles.getProjectFolder(), source);
- if (ignoreTestFolders && isTestFolder(sourceFolder.getName())) {
- continue;
- }
-
- builder.append(sourceTemplate.replace("", sourceFolder.getAbsolutePath()));
- builder.append("\n");
- }
-
- return builder.toString();
- }
-
- /**
- * Is test folder if the name ends with '-test'
- */
- private static boolean isTestFolder(String srcFoldername) {
- int dashIndex = srcFoldername.lastIndexOf('-');
-
- // If no dash, return
- if (dashIndex == -1) {
- return false;
- }
-
- // If no chars after dash, return
- if (dashIndex == srcFoldername.length() - 1) {
- return false;
- }
- String suffix = srcFoldername.substring(dashIndex + 1);
-
- return suffix.equals("test");
- }
-
- public static String getJUnitTargetName(String projectName) {
- return "junit_" + projectName;
- }
-
- public static String getBenchmarkerTargetName(String projectName) {
- return "bench_" + projectName;
- }
-
- public static String buildJUnitSources(ClasspathFiles classpathFiles) {
- String template = " \">\n" +
- " \n" +
- " \n" +
- " ";
-
- StringBuilder builder = new StringBuilder();
-
- for (String sourceFolder : classpathFiles.getSourceFolders()) {
- File src = new File(classpathFiles.getProjectFolder(), sourceFolder);
- String parsedTemplate = template.replace("", src.getAbsolutePath());
-
- builder.append(parsedTemplate).append("\n");
- }
-
- return builder.toString();
- }
-
- public static String buildBenchmarkerSources(ClasspathFiles classpathFiles) {
- String template = " \">\n" +
- " \n" +
- " ";
-
- StringBuilder builder = new StringBuilder();
-
- for (String sourceFolder : classpathFiles.getSourceFolders()) {
- File src = new File(classpathFiles.getProjectFolder(), sourceFolder);
- String parsedTemplate = template.replace("", src.getAbsolutePath());
-
- builder.append(parsedTemplate).append("\n");
- }
-
- return builder.toString();
- }
-
- /**
- * Creates a copy task for each source folder.
- */
- public static String getCopyTask(ClasspathFiles classpathFiles) {
-
- // Check if it has 'resources' folder
- List sources = classpathFiles.getSourceFolders();
- if (sources.isEmpty()) {
- return "";
- }
-
- // String template = "\">\n" +
- // " \" includes=\"**/*\">\n" +
- // " \" includes=\"**/*\">\n" +
- // " ";
-
- StringBuilder builder = new StringBuilder();
-
- for (String source : sources) {
- // Create copy task
- // Replacer replacer = new Replacer(template);
- Replacer replacer = new Replacer(BuildResource.COPY_TEMPLATE);
-
- File resourceFolder = new File(classpathFiles.getProjectFolder(), source);
-
- replacer.replace("", getBinFoldername(classpathFiles));
- replacer.replace("", resourceFolder.getAbsolutePath());
-
- builder.append(replacer.toString());
- }
-
- return builder.toString();
- /*
- boolean hasResources = false;
- for (String source : sources) {
- if (source.equals(RESOURCES_FOLDER)) {
- hasResources = true;
- break;
- }
- }
-
- if (!hasResources) {
- return "";
- }
- */
- /*
- // Create copy task
- Replacer replacer = new Replacer(template);
-
- File resourceFolder = new File(classpathFiles.getProjectFolder(), RESOURCES_FOLDER);
-
- replacer.replace("", getBinFolder(classpathFiles));
- replacer.replace("", resourceFolder.getAbsolutePath());
-
- return replacer.toString();
- */
- }
-
- public static String getResolveTask(ClasspathFiles classpathFiles) {
- // public static String getResolveTask(ClasspathParser parser, String projectName) {
- // ClasspathFiles classpathFiles = parser.getClasspath(projectName);
-
- if (!classpathFiles.getIvyPath().isPresent()) {
- // if (!parser.usesIvy()) {
- return "";
- }
-
- String ivyFile = new File(classpathFiles.getProjectFolder(), classpathFiles.getIvyPath().get())
- .getAbsolutePath();
-
- Replacer replacer = new Replacer(BuildResource.RESOLVE_TEMPLATE);
-
- replacer.replace("", getIvyTargetName(classpathFiles.getProjectName()));
- replacer.replace("", ivyFile);
- replacer.replace("", getIvyJarFoldername(classpathFiles.getProjectFolder()));
-
- return replacer.toString();
- }
-
- // All resolve targets resolves
- public static String getResolveTasks(ClasspathParser parser, Collection projects) {
-
- return projects.stream()
- .map(project -> getResolveTask(parser.getClasspath(project)))
- .filter(resolveTask -> !resolveTask.isEmpty())
- .collect(Collectors.joining("\n\n"));
- }
-
- public static String getIvyDependency(ClasspathParser parser) {
- if (parser.usesIvy()) {
- return "xmlns:ivy=\"antlib:org.apache.ivy.ant\"";
- }
-
- return "";
- }
-
- public static String getIvyDepends(Collection ivyProjects) {
- if (ivyProjects.isEmpty()) {
- return "";
- }
-
- return ivyProjects.stream()
- .map(projectName -> getIvyTargetName(projectName))
- .collect(Collectors.joining(",", "depends=\"", "\""));
-
- // return "depends=\"" +
-
- // getIvyTargetName(projectName) + "\"";
- }
-
- /**
- * Returns a collection of strings with projects that use Ivy to resolve dependencies.
- *
- * @param parser
- * @param dependentProjects
- * @return
- */
- public static Collection filterProjectsWithIvy(ClasspathParser parser,
- Collection dependentProjects) {
-
- return dependentProjects.stream()
- .filter(projectName -> parser.getClasspath(projectName).getIvyPath().isPresent())
- .collect(Collectors.toList());
-
- }
-
- public static String getCommandsTask(ClasspathFiles classpathFiles) {
- // If no commands file, return empty
- if (!classpathFiles.getCommandsFile().isPresent()) {
- return "";
- }
-
- StringBuilder tasks = new StringBuilder();
-
- final String commentPrefix = "#";
-
- // Read file, each line that is not a comment is a command
- try (LineStream lines = LineStream.newInstance(classpathFiles.getCommandsFile().get())) {
- while (lines.hasNextLine()) {
- String line = lines.nextLine().trim();
-
- // Ignore empty lines
- if (line.isEmpty()) {
- continue;
- }
-
- if (line.startsWith(commentPrefix)) {
- continue;
- }
-
- tasks.append(buildExecTask(line, classpathFiles.getProjectFolder())).append("\n");
- }
-
- }
-
- return tasks.toString();
-
- }
-
- private static String buildExecTask(String line, File projectFolder) {
- List arguments = ArgumentsParser.newCommandLine().parse(line);
-
- Preconditions.checkArgument(!arguments.isEmpty(), "Expected at least one argument:" + line);
-
- // Parser arguments for exec options
- ExecTaskConfig execTaskConfig = ExecTaskConfig.parseArguments(arguments);
-
- File workingDir = execTaskConfig.getWorkingDir()
- .map(dir -> new File(projectFolder, dir))
- .orElse(projectFolder);
-
- StringBuilder task = new StringBuilder();
-
- // First argument is the command (unless we use the first arg to indicate OS-specific commands)
- task.append("\n");
-
- // Add arguments
- for (int i = 1; i < arguments.size(); i++) {
- task.append(" \n");
- }
-
- // Close task
- task.append("\n");
- return task.toString();
- }
-
- /**
- * Helper method which uses the current working directory as the base folder.
- *
- * @return
- */
- public static String getReportsDir() {
- return getReportsDir(SpecsIo.getWorkingDir());
- }
-
- public static String getReportsDir(File baseFolder) {
- // public static String getReportsDir(File baseFolder, String foldernameSuffix) {
-
- // SpecsCheck.checkArgument(!foldernameSuffix.isBlank(), () -> "Foldername suffix cannot be empty.");
-
- File reportsFolder = SpecsIo.mkdir(baseFolder, REPORTS_FOLDERNAME);
-
- // Clean reports
- SpecsIo.deleteFolderContents(reportsFolder);
-
- return SpecsIo.getCanonicalPath(reportsFolder);
- }
-}
diff --git a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/CreateBuildXml.java b/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/CreateBuildXml.java
deleted file mode 100644
index 9f18e905..00000000
--- a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/CreateBuildXml.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/**
- * Copyright 2014 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.builder;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import pt.up.fe.specs.eclipse.Classpath.ClasspathFiles;
-import pt.up.fe.specs.eclipse.Classpath.ClasspathParser;
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.SpecsLogs;
-import pt.up.fe.specs.util.SpecsSystem;
-import pt.up.fe.specs.util.properties.SpecsProperty;
-import pt.up.fe.specs.util.utilities.LineStream;
-import pt.up.fe.specs.util.utilities.Replacer;
-
-/**
- * @author Joao Bispo
- *
- */
-public class CreateBuildXml {
-
- private static final boolean TEMP_IGNORE_TEST_FOLDERS = false;
-
- private static final String IGNORE_FILE_PROJECTS = "projects.buildignore";
- private static final String BENCHMARKER_FILE_PROJECTS = "projects.benchmarker";
- // private static final String FILE_PROJECTS_CACHE = "eclipse_projects.xml";
-
- public static final String JTEST_PROJECT_NAME = "projectName";
-
- public static File getBenchmarkerProjectsFile() {
- return new File(BENCHMARKER_FILE_PROJECTS);
- }
-
- private final File repFolder;
- private final ClasspathParser parser;
- private final Set projectsToIgnore;
- private final File ivySettingsFile;
- private final boolean ignoreTestFolders;
-
- public CreateBuildXml(File repFolder, ClasspathParser parser, Collection ignoreList, File ivySettingsFile) {
- this.repFolder = SpecsIo.getCanonicalFile(repFolder);
- this.parser = parser;
- projectsToIgnore = new HashSet<>(ignoreList);
- this.ivySettingsFile = ivySettingsFile;
- this.ignoreTestFolders = TEMP_IGNORE_TEST_FOLDERS;
- }
-
- public static void main(String args[]) {
- SpecsSystem.programStandardInit();
-
- SpecsProperty.ShowStackTrace.applyProperty("true");
-
- if (args.length < 2) {
- SpecsLogs
- .msgInfo(
- "Needs at least two arguments, the root of the repository and the user libraries file exported from Eclipse (.userlibraries). Optionally you can pass the ivy settings file");
- return;
- }
-
- File repFolder = SpecsIo.existingFolder(null, args[0]);
- if (repFolder == null) {
- return;
- }
-
- // File parsedInfo = IoUtils.existingFile(args[1]);
- // ClasspathParser parser = XStreamUtils.read(parsedInfo, ClasspathParser.class);
-
- File userLibrariesFile = SpecsIo.existingFile(repFolder, args[1]);
-
- ClasspathParser parser = ClasspathParser.newInstance(repFolder, userLibrariesFile);
-
- File ivySettingsFile = null;
- if (args.length > 2) {
- ivySettingsFile = SpecsIo.existingFile(args[2]);
- }
-
- // Save classparser
- // XStreamUtils.write(new File(repFolder, CreateBuildXml.FILE_PROJECTS_CACHE), parser);
-
- CreateBuildXml buildXml = new CreateBuildXml(repFolder, parser, getIgnoreList(), ivySettingsFile);
- buildXml.execute();
- }
-
- /*
- public static Optional loadCachedInfo(File folder) {
- File cachedInfo = new File(folder, CreateBuildXml.FILE_PROJECTS_CACHE);
- if (!cachedInfo.isFile()) {
- return Optional.empty();
- }
-
- return Optional
- .of(XStreamUtils.read(new File(folder, CreateBuildXml.FILE_PROJECTS_CACHE), ClasspathParser.class));
- }
- */
-
- private static List getIgnoreList() {
- return parseProjectsList(new File(CreateBuildXml.IGNORE_FILE_PROJECTS));
- }
-
- private static List getBenchmarkerList() {
- return parseProjectsList(new File(CreateBuildXml.BENCHMARKER_FILE_PROJECTS));
- }
-
- public static List parseProjectsList(File file) {
- // If files does not exists, return empty list
- if (!file.isFile()) {
- return Collections.emptyList();
- }
-
- // Parse file
- return LineStream.newInstance(file).stream()
- // Remove comments
- .filter(line -> !line.startsWith("#"))
- // Collect project names
- .collect(Collectors.toList());
- }
-
- // public static Set parseProjectList(File file) {
- // return new LinkedHashSet<>(getProjectsList(file));
- // }
-
- /**
- *
- */
- public void execute() {
- // Build all projects
- buildProjects();
- }
-
- private void buildProjects() {
-
- List projectNames = getProjectNames();
-
- // Build clean
- String clean = buildClean(projectNames);
-
- // Build compilation targets
- StringBuilder compileTargets = new StringBuilder();
- for (String projectName : projectNames) {
- // Check if project is in ignore list
-
- String compileTarget = buildCompileTarget(projectName);
- compileTargets.append(compileTarget);
- compileTargets.append("\n");
- }
-
- // Build junit targets
- StringBuilder junitTargets = new StringBuilder();
- for (String projectName : projectNames) {
- String junitTarget = buildJUnitTarget(projectName);
- junitTargets.append(junitTarget);
- junitTargets.append("\n");
- }
-
- // Build benchmarker target
- String benchmarkerTarget = buildBenchmarkerTarget();
-
- String ivyImport = BuildUtils.getIvyDependency(parser);
-
- Replacer antBuild = new Replacer(BuildResource.MAIN_TEMPLATE);
-
- antBuild.replace("", ivyImport);
- antBuild.replace("", getIvySettings());
- antBuild.replace("", clean);
- antBuild.replace("", BuildUtils.getDependenciesSuffix(projectNames));
- antBuild.replace("", compileTargets.toString());
-
- antBuild.replace("", BuildUtils.getJUnitTargetDependencies(projectNames));
- antBuild.replace("", junitTargets.toString());
- antBuild.replace("", benchmarkerTarget);
-
- // Save script
- File buildFile = new File(repFolder, "build_test.xml");
-
- SpecsIo.write(buildFile, antBuild.toString());
- SpecsLogs.msgInfo("ANT Build file written (" + buildFile + ")");
-
- }
-
- private String buildBenchmarkerTarget() {
- List projectNames = getBenchmarkerList();
-
- StringBuilder benchTargets = new StringBuilder();
- for (String projectName : projectNames) {
- String benchTarget = buildBenchmarkerTarget(projectName);
- benchTargets.append(benchTarget);
- benchTargets.append("\n");
- }
-
- // Build target benchmarker that call all benchmarker targets
-
- String benchmarkerTarget = projectNames.stream()
- .map(projectName -> BuildUtils.getBenchmarkerTargetName(projectName))
- .collect(Collectors.joining(",", ""));
-
- benchTargets.append(benchmarkerTarget);
-
- return benchTargets.toString();
- }
-
- private String getIvySettings() {
- if (ivySettingsFile == null) {
- return "";
- }
-
- return "\n";
- }
-
- private String buildClean(List projectNames) {
- if (projectNames.isEmpty()) {
- return "";
- }
-
- StringBuilder builder = new StringBuilder();
-
- for (String projectName : projectNames) {
-
- // Add delete for /bin folders
- Replacer template = new Replacer(BuildResource.DELETE_TEMPLATE);
- template.replace("", BuildUtils.getBinFoldername(parser.getClasspath(projectName)));
- builder.append(template.toString()).append("\n");
-
- // Add delete for /ivy folders, if project uses it
- if (parser.getClasspath(projectName).getIvyPath().isPresent()) {
- Replacer ivyTemplate = new Replacer(BuildResource.DELETE_TEMPLATE);
- String ivyFolder = BuildUtils.getIvyJarFoldername(parser.getClasspath(projectName).getProjectFolder());
- // Make sure folder exists, to avoid errors during ANT run
- SpecsIo.mkdir(ivyFolder);
- ivyTemplate.replace("", ivyFolder);
- builder.append(ivyTemplate.toString()).append("\n");
- }
-
- // parser.getClasspath(projectName).getIvyPath().ifPresent(
- // ivyPath -> System.out.println("Project '" + projectName + "' uses ivy (" + ivyPath + ")"));
-
- }
-
- return builder.toString();
- }
-
- private String buildJUnitTarget(String projectName) {
- ClasspathFiles classpathFiles = parser.getClasspath(projectName);
-
- String targetName = BuildUtils.getJUnitTargetName(projectName);
- String compileTargetName = BuildUtils.getCompileTargetName(projectName);
- String testsFolder = classpathFiles.getProjectFolder().getAbsolutePath();
- String binFoldername = BuildUtils.getBinFoldername(classpathFiles);
- String fileset = BuildUtils.buildFileset(projectName, parser);
- String junitSourceFolders = BuildUtils.buildJUnitSources(classpathFiles);
-
- // File reportsFolder = SpecsIo.mkdir(repFolder, "reports");
- //
- // // Clean reports
- // SpecsIo.deleteFolderContents(reportsFolder);
- //
- // String reportsDir = reportsFolder.getAbsolutePath();
-
- String reportsDir = BuildUtils.getReportsDir(repFolder);
-
- Replacer projectBuild = new Replacer(BuildResource.JUNIT_TEMPLATE);
-
- projectBuild.replace("", targetName);
- projectBuild.replace("", compileTargetName);
- projectBuild.replace("", projectName);
- projectBuild.replace("", testsFolder);
- projectBuild.replace("", fileset);
- projectBuild.replace("", binFoldername);
- projectBuild.replace("", junitSourceFolders);
- projectBuild.replace("", reportsDir);
-
- return projectBuild.toString();
- }
-
- private String buildBenchmarkerTarget(String projectName) {
- ClasspathFiles classpathFiles = parser.getClasspath(projectName);
-
- String targetName = BuildUtils.getBenchmarkerTargetName(projectName);
- String testsFolder = classpathFiles.getProjectFolder().getAbsolutePath();
- String binFoldername = BuildUtils.getBinFoldername(classpathFiles);
- String fileset = BuildUtils.buildFileset(projectName, parser);
- String junitSourceFolders = BuildUtils.buildBenchmarkerSources(classpathFiles);
-
- // File reportsFolder = SpecsIo.mkdir(repFolder, "reports");
- //
- // // Clean reports
- // SpecsIo.deleteFolderContents(reportsFolder);
- //
- // String reportsDir = reportsFolder.getAbsolutePath();
-
- String reportsDir = BuildUtils.getReportsDir(repFolder);
-
- Replacer projectBuild = new Replacer(BuildResource.BENCHMARKER_TEMPLATE);
-
- projectBuild.replace("", targetName);
- projectBuild.replace("", projectName);
- projectBuild.replace("", testsFolder);
- projectBuild.replace("", fileset);
- projectBuild.replace("", binFoldername);
- projectBuild.replace("", junitSourceFolders);
- projectBuild.replace("", reportsDir);
-
- return projectBuild.toString();
- }
-
- private List getProjectNames() {
- List projectNames = new ArrayList<>();
-
- // Get all projects
- for (String projectName : parser.getEclipseProjects().getProjectNames()) {
-
- // If cannot get classpath files for any reason, ignore it
- // (i.e., project is not supposed to be built and does not contain a .classpath file.
- Optional classpathFiles = getClasspath(projectName);
- if (!classpathFiles.isPresent()) {
- SpecsLogs.msgInfo("Skipping project '" + projectName + "' (could not get classpath information)");
- continue;
- }
-
- // Ignore project if it does not have sources
- if (classpathFiles.get().getSourceFolders().isEmpty()) {
- SpecsLogs.msgInfo("Skipping project '" + projectName + "' (no source folder found)");
- continue;
- }
-
- // Ignore project if in ignore list
- if (projectsToIgnore.contains(projectName)) {
- SpecsLogs.msgInfo("Skipping project '" + projectName + "' (it is in ignore list)");
- continue;
- }
-
- projectNames.add(projectName);
- }
-
- return projectNames;
- }
-
- private Optional getClasspath(String projectName) {
- try {
- return Optional.of(parser.getClasspath(projectName));
- } catch (Exception e) {
- return Optional.empty();
- }
- }
-
- private String buildCompileTarget(String projectName) {
- ClasspathFiles classpathFiles = parser.getClasspath(projectName);
-
- String targetName = BuildUtils.getCompileTargetName(projectName);
- // String projectDependencies = BuildUtils.getDependencies(classpathFiles.getParentProjects());
- String projectDependencies = BuildUtils.getDependencies(classpathFiles);
-
- String outputJar = BuildUtils.getOutputJar(projectName).getAbsolutePath();
- String fileset = BuildUtils.buildFileset(projectName, parser);
- String binFoldername = BuildUtils.getBinFoldername(classpathFiles);
- String sourcePath = BuildUtils.getSourcePath(classpathFiles, ignoreTestFolders);
- String copyTask = BuildUtils.getCopyTask(classpathFiles);
- String ivyResolve = BuildUtils.getResolveTask(classpathFiles);
- String commands = BuildUtils.getCommandsTask(classpathFiles);
- // String ivyResolve = BuildUtils.getResolveTask(parser, projectName);
-
- Replacer projectBuild = new Replacer(BuildResource.COMPILE_TEMPLATE);
-
- projectBuild.replace("", targetName);
- projectBuild.replace("", projectDependencies);
- projectBuild.replace("", commands);
- projectBuild.replace("", outputJar);
- projectBuild.replace("", fileset);
- projectBuild.replace("", projectName);
- projectBuild.replace("", binFoldername);
- projectBuild.replace("", sourcePath);
- projectBuild.replace("", copyTask);
- projectBuild.replace("", ivyResolve);
- projectBuild.replace("", ""); // Disabled
-
- return projectBuild.toString();
- }
-
-}
diff --git a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/ExecTaskConfig.java b/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/ExecTaskConfig.java
deleted file mode 100644
index 93ee37e9..00000000
--- a/EclipseUtils/builds/pt/up/fe/specs/eclipse/builder/ExecTaskConfig.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright 2017 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.builder;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-
-import com.google.common.base.Preconditions;
-
-public class ExecTaskConfig {
-
- private static final Set SUPPORTED_PROPERTIES = new HashSet<>(Arrays.asList("dir"));
-
- private final String workingDir;
-
- public ExecTaskConfig(String workingDir) {
- this.workingDir = workingDir;
- }
-
- public Optional getWorkingDir() {
- return Optional.ofNullable(workingDir);
- }
-
- public static ExecTaskConfig parseArguments(List arguments) {
- String workingDir = null;
-
- while (!arguments.isEmpty() && arguments.get(0).startsWith("[")) {
- String option = arguments.remove(0);
- // Remove square brackets
- Preconditions.checkArgument(option.endsWith("]"), "Expected option to end with ]: " + option);
-
- String workOption = option.substring(1, option.length() - 1);
-
- int equalIndex = workOption.indexOf('=');
- Preconditions.checkArgument(equalIndex != -1, "Expected an equals: " + option);
-
- String key = workOption.substring(0, equalIndex);
- String value = workOption.substring(equalIndex + 1, workOption.length());
- switch (key.toLowerCase()) {
- case "dir":
- workingDir = value;
- break;
- default:
- throw new RuntimeException(
- "Property '" + key + "' not supported, supported properties: " + SUPPORTED_PROPERTIES);
- }
- }
-
- return new ExecTaskConfig(workingDir);
- }
-}
diff --git a/EclipseUtils/resources/build/compile.xml.template b/EclipseUtils/resources/build/compile.xml.template
deleted file mode 100644
index 121a5c24..00000000
--- a/EclipseUtils/resources/build/compile.xml.template
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
- >
-
-
-
- >
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/resources/build/copy.xml.template b/EclipseUtils/resources/build/copy.xml.template
deleted file mode 100644
index cea91d39..00000000
--- a/EclipseUtils/resources/build/copy.xml.template
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/build/delete.xml.template b/EclipseUtils/resources/build/delete.xml.template
deleted file mode 100644
index 22df22cb..00000000
--- a/EclipseUtils/resources/build/delete.xml.template
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/build/hamcrest.core.jar b/EclipseUtils/resources/build/hamcrest.core.jar
deleted file mode 100644
index 0adbff11..00000000
Binary files a/EclipseUtils/resources/build/hamcrest.core.jar and /dev/null differ
diff --git a/EclipseUtils/resources/build/jarfolder.template b/EclipseUtils/resources/build/jarfolder.template
deleted file mode 100644
index f1e0c4fb..00000000
--- a/EclipseUtils/resources/build/jarfolder.template
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/build/junit.jar b/EclipseUtils/resources/build/junit.jar
deleted file mode 100644
index 3a7fc266..00000000
Binary files a/EclipseUtils/resources/build/junit.jar and /dev/null differ
diff --git a/EclipseUtils/resources/build/junit.xml.template b/EclipseUtils/resources/build/junit.xml.template
deleted file mode 100644
index 8f805f37..00000000
--- a/EclipseUtils/resources/build/junit.xml.template
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/build/main.xml.template b/EclipseUtils/resources/build/main.xml.template
deleted file mode 100644
index 26643dac..00000000
--- a/EclipseUtils/resources/build/main.xml.template
+++ /dev/null
@@ -1,24 +0,0 @@
-
->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/build/resolve.xml.template b/EclipseUtils/resources/build/resolve.xml.template
deleted file mode 100644
index b3e71d04..00000000
--- a/EclipseUtils/resources/build/resolve.xml.template
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/build/run.benchmarker.template b/EclipseUtils/resources/build/run.benchmarker.template
deleted file mode 100644
index 6639fce8..00000000
--- a/EclipseUtils/resources/build/run.benchmarker.template
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/build/target.xml.template b/EclipseUtils/resources/build/target.xml.template
deleted file mode 100644
index 64426304..00000000
--- a/EclipseUtils/resources/build/target.xml.template
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/deploy.xml.template b/EclipseUtils/resources/deploy.xml.template
deleted file mode 100644
index 0199028a..00000000
--- a/EclipseUtils/resources/deploy.xml.template
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/resources/deploy/deploy_maven_repo.xml.template b/EclipseUtils/resources/deploy/deploy_maven_repo.xml.template
deleted file mode 100644
index 8bb706b0..00000000
--- a/EclipseUtils/resources/deploy/deploy_maven_repo.xml.template
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/resources/deploy/deploy_maven_script.bat.template b/EclipseUtils/resources/deploy/deploy_maven_script.bat.template
deleted file mode 100644
index b49a237c..00000000
--- a/EclipseUtils/resources/deploy/deploy_maven_script.bat.template
+++ /dev/null
@@ -1,3 +0,0 @@
-mvn gpg:sign-and-deploy-file "-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/" "-DrepositoryId=ossrh" "-DpomFile=%POM_FILE%" "-Dfile=%JAR_FILE%"
-mvn gpg:sign-and-deploy-file "-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/" "-DrepositoryId=ossrh" "-DpomFile=%POM_FILE%" "-Dfile=%SOURCE_FILE%" "-Dclassifier=sources"
-mvn gpg:sign-and-deploy-file "-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/" "-DrepositoryId=ossrh" "-DpomFile=%POM_FILE%" "-Dfile=%JAVADOC_FILE%" "-Dclassifier=javadoc"
\ No newline at end of file
diff --git a/EclipseUtils/resources/deploy/deploy_onejar.xml.template b/EclipseUtils/resources/deploy/deploy_onejar.xml.template
deleted file mode 100644
index 593d8e65..00000000
--- a/EclipseUtils/resources/deploy/deploy_onejar.xml.template
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/resources/deploy/deploy_pom.xml.template b/EclipseUtils/resources/deploy/deploy_pom.xml.template
deleted file mode 100644
index 1b3dea39..00000000
--- a/EclipseUtils/resources/deploy/deploy_pom.xml.template
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- 4.0.0
-
- %GROUP_ID%
- %ARTIFACT_ID%
- %VERSION%
- jar
-
- %NAME%
- %DESCRIPTION%
- %URL%
-
-
-%LICENSES%
-
-
-
-%DEVELOPERS%
-
-
-
- scm:git:git://github.com/%GITHUB_PROJECT%.git
- scm:git:ssh://github.com:%GITHUB_PROJECT%.git
- http://github.com/%GITHUB_PROJECT%/tree/master
-
-
-
-
-%DEPENDENCIES%
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/deploy/deploy_repack.xml.template b/EclipseUtils/resources/deploy/deploy_repack.xml.template
deleted file mode 100644
index cc44786c..00000000
--- a/EclipseUtils/resources/deploy/deploy_repack.xml.template
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/resources/deploy/deploy_subfolder_zip.xml.template b/EclipseUtils/resources/deploy/deploy_subfolder_zip.xml.template
deleted file mode 100644
index 73eea728..00000000
--- a/EclipseUtils/resources/deploy/deploy_subfolder_zip.xml.template
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/resources/ftp.xml.template b/EclipseUtils/resources/ftp.xml.template
deleted file mode 100644
index 18d40313..00000000
--- a/EclipseUtils/resources/ftp.xml.template
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/resources/jar-in-jar-loader.zip b/EclipseUtils/resources/jar-in-jar-loader.zip
deleted file mode 100644
index 6ee12176..00000000
Binary files a/EclipseUtils/resources/jar-in-jar-loader.zip and /dev/null differ
diff --git a/EclipseUtils/resources/resolveIvy.xml.template b/EclipseUtils/resources/resolveIvy.xml.template
deleted file mode 100644
index 73a2a8d0..00000000
--- a/EclipseUtils/resources/resolveIvy.xml.template
+++ /dev/null
@@ -1,11 +0,0 @@
-
- >
-
-
-
-
-
- >
-
-
-
\ No newline at end of file
diff --git a/EclipseUtils/resources/sftp.xml.template b/EclipseUtils/resources/sftp.xml.template
deleted file mode 100644
index 637e478d..00000000
--- a/EclipseUtils/resources/sftp.xml.template
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/run/CreateBuildXml-run.launch b/EclipseUtils/run/CreateBuildXml-run.launch
deleted file mode 100644
index 2fd53c1b..00000000
--- a/EclipseUtils/run/CreateBuildXml-run.launch
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/run/EclipseDeployment-run.launch b/EclipseUtils/run/EclipseDeployment-run.launch
deleted file mode 100644
index 2c312619..00000000
--- a/EclipseUtils/run/EclipseDeployment-run.launch
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EclipseUtils/settings.gradle b/EclipseUtils/settings.gradle
deleted file mode 100644
index daa796b2..00000000
--- a/EclipseUtils/settings.gradle
+++ /dev/null
@@ -1,7 +0,0 @@
-rootProject.name = 'EclipseUtils'
-
-includeBuild("../../specs-java-libs/CommonsLangPlus")
-includeBuild("../../specs-java-libs/GuiHelper")
-includeBuild("../../specs-java-libs/SpecsUtils")
-includeBuild("../../specs-java-libs/XStreamPlus")
-includeBuild("../../specs-java-libs/jOptions")
diff --git a/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/GitBranch.java b/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/GitBranch.java
deleted file mode 100644
index 1e352468..00000000
--- a/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/GitBranch.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Copyright 2015 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.psfbuilder;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Set;
-
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.lib.StoredConfig;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.SpecsLogs;
-
-public class GitBranch {
-
- // private static final String GIT_FOLDER = ".git";
- private static final String DEFAULT_REMOTE = "origin";
- private static final String DEFAULT_BRANCH = "master";
-
- private final File workingTree;
- private final String remote;
- private final String branch;
-
- public GitBranch(File workingTree, String remote, String branch) {
- this.workingTree = workingTree;
- this.remote = remote;
- this.branch = branch;
- }
-
- public String getBranch() {
- return branch;
- }
-
- public String getRemote() {
- return remote;
- }
-
- public File getWorkingTree() {
- return workingTree;
- }
-
- public static GitBranch newInstance(File location) {
- FileRepositoryBuilder repoBuilder = new FileRepositoryBuilder()
- .findGitDir(location.getAbsoluteFile());
-
- if (repoBuilder.getGitDir() == null) {
- throw new RuntimeException("Could not find a git repository for folder '"
- + SpecsIo.getWorkingDir().getAbsolutePath() + "'");
- }
-
- // Open an existing repository
- try (Repository repo = repoBuilder.build()) {
- StoredConfig config = repo.getConfig();
- Set remotes = config.getSubsections("remote");
-
- if (remotes.isEmpty()) {
- throw new RuntimeException("Could not find a remote in '" + repo.getWorkTree() + "'");
- }
-
- // Get a remote. Try origin first, if not found, get the first on the list
- String remoteName = getRemoteName(remotes);
- String remote = config.getString("remote", remoteName, "url");
-
- Set branches = config.getSubsections("branch");
- if (branches.isEmpty()) {
- throw new RuntimeException("Could not find a branch in '" + repo.getWorkTree() + "'");
- }
-
- String branch = getBranchName(branches);
-
- return new GitBranch(repo.getWorkTree(), remote, branch);
- } catch (IOException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
-
- }
-
- private static String getBranchName(Set branches) {
- if (branches.contains(DEFAULT_BRANCH)) {
- return DEFAULT_BRANCH;
- }
-
- String firstBranch = branches.stream().findFirst().get();
-
- SpecsLogs.msgInfo("Could not find branch '" + DEFAULT_BRANCH + "', returning the first branch found, '"
- + firstBranch + "'");
-
- return firstBranch;
- }
-
- private static String getRemoteName(Set remotes) {
- if (remotes.contains(DEFAULT_REMOTE)) {
- return DEFAULT_REMOTE;
- }
-
- String firstRemote = remotes.stream().findFirst().get();
-
- SpecsLogs.msgInfo("Could not find remote '" + DEFAULT_REMOTE + "', returning the first remote found, '"
- + firstRemote + "'");
-
- return firstRemote;
- }
-
- @Override
- public String toString() {
- return getRemote() + ";" + getBranch();
- }
-}
diff --git a/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/PsfBuilder.java b/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/PsfBuilder.java
deleted file mode 100644
index 0828e62e..00000000
--- a/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/PsfBuilder.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * Copyright 2015 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.psfbuilder;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringJoiner;
-import java.util.TreeSet;
-
-import pt.up.fe.specs.eclipse.Classpath.ClasspathFiles;
-import pt.up.fe.specs.eclipse.Classpath.ClasspathParser;
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.SpecsLogs;
-import pt.up.fe.specs.util.SpecsSystem;
-import pt.up.fe.specs.util.utilities.ProgressCounter;
-import pt.up.fe.specs.util.utilities.Replacer;
-
-public class PsfBuilder {
-
- // private static final boolean OVERWRITE_EXISTING_PSF = true;
- private static final String PSF_DEPENDENCY_TEMPLATE = ",,\"/>";
-
- private final ClasspathParser eclipseProjects;
- private final List compulsoryProjects;
-
- public PsfBuilder(ClasspathParser eclipseProjects, List compulsoryProjects) {
- this.eclipseProjects = eclipseProjects;
- this.compulsoryProjects = compulsoryProjects;
- }
-
- public static void main(String[] args) {
- SpecsSystem.programStandardInit();
-
- // Accepts one argument, a folder which will be search recursively for project folders
- if (args.length == 0) {
- SpecsLogs
- .msgInfo(
- "Accepts one argument, a folder which will be search recursively for project folders, and optionally a user.libraries file (to avoid warnings). All remaining arguments will be interpreted as project names that should always be added to the dependencies.");
- return;
- }
-
- File projectsFolder = SpecsIo.existingFolder(args[0]);
-
- // Get all projects from folder
- ClasspathParser eclipseProjects;
- if (args.length < 2) {
- eclipseProjects = ClasspathParser.newInstance(projectsFolder);
- } else {
- eclipseProjects = ClasspathParser.newInstance(projectsFolder, new File(args[1]));
- }
-
- List compulsoryProjects = new ArrayList<>();
- for (int i = 2; i < args.length; i++) {
- compulsoryProjects.add(args[i]);
- }
-
- PsfBuilder builder = new PsfBuilder(eclipseProjects, compulsoryProjects);
- builder.build();
- }
-
- private void build() {
- ProgressCounter counter = new ProgressCounter(eclipseProjects.getEclipseProjects().getProjectNames().size());
- // For each project, build a psf file, if not present
- for (String projectName : eclipseProjects.getEclipseProjects().getProjectNames()) {
- SpecsLogs.msgInfo("Writing import file for project '" + projectName + "' " + counter.next());
- File projectFolder = eclipseProjects.getEclipseProjects().getProjectFolder(projectName);
- addPsfFile(projectName, projectFolder);
- }
- }
-
- private void addPsfFile(String projectName, File projectFolder) {
- // Check if project folder already has a PSF file
- /*
- if (!IoUtils.getFiles(projectFolder, "psf").isEmpty() && !OVERWRITE_EXISTING_PSF) {
- // if (IoUtils.getFiles(projectFolder, "psf").isEmpty()) {
- LoggingUtils.msgInfo("Project '" + projectName + "' already has a .psf file, skipping");
- return;
- }
- */
-
- // Get list of dependent projects
- ClasspathFiles classpath = eclipseProjects.getClasspath(projectName);
- List projects = classpath.getDependentProjects();
-
- // If no projects, ignore
- if (projects.isEmpty() && compulsoryProjects.isEmpty()) {
- SpecsLogs.msgInfo(" - Ignoring project, does not have project dependencies");
- return;
- }
-
- // Add self
- projects.add(projectName);
-
- // Add compulsory projects
- Set currentProjects = new HashSet<>(projects);
- for (String compulsoryProject : compulsoryProjects) {
- if (currentProjects.contains(compulsoryProject)) {
- continue;
- }
-
- projects.add(compulsoryProject);
- }
-
- // Sort dependencies alphabetically
- Set sortedProjects = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
- sortedProjects.addAll(projects);
-
- String psfDependencies = buildPsfDependencies(sortedProjects);
-
- Replacer psfContents = new Replacer(PsfResource.PROJECT_PSF);
-
- psfContents.replace("", psfDependencies);
-
- File psfFile = new File(projectFolder, "projectSet.psf");
-
- SpecsIo.write(psfFile, psfContents.toString());
-
- }
-
- private String buildPsfDependencies(Collection projects) {
- StringJoiner joiner = new StringJoiner(SpecsIo.getNewline());
- for (String project : projects) {
- String psfDependency = getPsfDependency(project);
- joiner.add(psfDependency);
- }
-
- return joiner.toString();
- }
-
- private String getPsfDependency(String project) {
- File projectFolder = eclipseProjects.getEclipseProjects().getProjectFolder(project);
- // Get GitBranch for project
- GitBranch gitBranch = GitBranch.newInstance(projectFolder);
- String remote = getRemote(gitBranch);
- String branch = gitBranch.getBranch();
-
- String relativePath = SpecsIo.getRelativePath(projectFolder, gitBranch.getWorkingTree());
-
- Replacer replacer = new Replacer(PSF_DEPENDENCY_TEMPLATE);
- replacer.replace("", remote);
- replacer.replace("", branch);
- replacer.replace("", relativePath);
-
- return replacer.toString();
- }
-
- /*
- private static Optional getGitRepo(File startLocation) {
- // Get current folder
- File currentParent = startLocation.getAbsoluteFile().getParentFile();
- System.out.println("CURRENT:" + currentParent);
- while (currentParent != null) {
- // Check if it has a .git folder
- File gitFolder = new File(currentParent, GIT_FOLDER);
- if (gitFolder.isDirectory()) {
- return Optional.of(gitFolder);
- }
-
- currentParent = currentParent.getParentFile();
- }
-
- return Optional.empty();
- }
- */
-
- private static String getRemote(GitBranch gitBranch) {
- String originalRemote = gitBranch.getRemote();
-
- // Remove user information from remote
- int index = originalRemote.indexOf("//");
- int atIndex = originalRemote.indexOf("@");
-
- if (index == -1 || atIndex == -1) {
- return originalRemote;
- }
-
- return originalRemote.substring(0, index + 2) + originalRemote.substring(atIndex + 1);
- }
-
-}
diff --git a/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/PsfResource.java b/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/PsfResource.java
deleted file mode 100644
index f7e014ff..00000000
--- a/EclipseUtils/src-psfbuilder/pt/up/fe/specs/psfbuilder/PsfResource.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.psfbuilder;
-
-import pt.up.fe.specs.util.providers.ResourceProvider;
-
-/**
- * @author Joao Bispo
- *
- */
-public enum PsfResource implements ResourceProvider {
-
- PROJECT_PSF("psf_template.psf");
-
- private final static String RESOURCE_FOLDER = "psfbuilder";
-
- private final String resource;
-
- private PsfResource(String resource) {
- this.resource = RESOURCE_FOLDER + "/" + resource;
- }
-
- /* (non-Javadoc)
- * @see pt.up.fe.specs.util.Interfaces.ResourceProvider#getResource()
- */
- @Override
- public String getResource() {
- return resource;
- }
-
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/ClasspathFiles.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/ClasspathFiles.java
deleted file mode 100644
index 0fffbcbc..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/ClasspathFiles.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.Classpath;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import pt.up.fe.specs.eclipse.builder.BuildUtils;
-import pt.up.fe.specs.util.SpecsCheck;
-
-/**
- * @author Joao Bispo
- *
- */
-public class ClasspathFiles {
-
- private static final String COMMANDS_FILENAME = "commands.build";
-
- public static String getCommandsFilename() {
- return COMMANDS_FILENAME;
- }
-
- private final String projectName;
- private final File projectFolder;
- private final List sourceFolders;
- private final Map projectFolders;
- private final List jarFiles;
- private final List parentProjects;
- private final Optional ivyPath;
- private final List projectsWithIvy;
- private final File commandsFile;
-
- public ClasspathFiles(String projectName, File projectFolder, List sourceFolders,
- Map projectFolders, List jarFiles, Optional ivyPath,
- List projectsWithIvy, File commandsFile) {
-
- this.projectName = projectName;
- this.projectFolder = projectFolder;
- this.projectFolders = projectFolders;
- this.sourceFolders = sourceFolders;
- this.jarFiles = jarFiles;
- this.ivyPath = ivyPath;
- this.projectsWithIvy = projectsWithIvy;
- this.commandsFile = commandsFile;
- parentProjects = buildParentProjects(projectName, projectFolders);
- }
-
- private static List buildParentProjects(String projectName, Map projectFolders) {
- List parentProjects = new ArrayList<>();
-
- for (String name : projectFolders.keySet()) {
- // Parse name
- if (name.startsWith("/")) {
- name = name.substring(1);
- }
-
- // Do not include the project itself
- if (name.equals(projectName)) {
- continue;
- }
-
- parentProjects.add(name);
- }
-
- return parentProjects;
- }
-
- public Optional getCommandsFile() {
- return Optional.ofNullable(commandsFile);
- }
-
- public boolean usesIvy() {
- return getIvyPath().isPresent();
- }
-
- public Optional getIvyPath() {
- return ivyPath;
- }
-
- public Optional getIvyFile() {
- Optional ivyFile = getIvyPath().map(ivyPath -> new File(getProjectFolder(), ivyPath));
- if (ivyFile.isPresent()) {
- SpecsCheck.checkArgument(ivyFile.get().isFile(), () -> "Could not find ivy file '" + ivyFile.get() + "'");
- }
-
- return ivyFile;
- }
-
- public Optional getIvyJarFolder() {
- if (!getIvyPath().isPresent()) {
- return Optional.empty();
- }
-
- return Optional.of(BuildUtils.getIvyJarFolder(getProjectFolder()));
- }
-
- public String getProjectName() {
- return projectName;
- }
-
- /**
- * @return the jarFiles
- */
- public List getJarFiles() {
- return jarFiles;
- }
-
- /**
- * @return the projectFolders
- */
- public Collection getBinFolders() {
- // return projectFolders;
- return projectFolders.values();
- }
-
- public List getDependentProjects() {
- return parentProjects;
- }
-
- public File getProjectFolder() {
- return projectFolder;
- }
-
- public List getSourceFolders() {
- return sourceFolders;
- }
-
- /**
- *
- * @return the source folders of this project
- */
- public List getSources() {
- return getSourceFolders().stream()
- .map(src -> new File(getProjectFolder(), src))
- .collect(Collectors.toList());
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "Project Folders:" + projectFolders + "\n" + "Jar Files:" + jarFiles;
- }
-
- public List getProjectsWithIvy() {
- return projectsWithIvy;
- }
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/ClasspathParser.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/ClasspathParser.java
deleted file mode 100644
index 5de3f12b..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/ClasspathParser.java
+++ /dev/null
@@ -1,666 +0,0 @@
-/**
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.Classpath;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import com.google.common.base.Preconditions;
-
-// import nu.xom.Attribute;
-// import nu.xom.Document;
-// import nu.xom.Element;
-// import nu.xom.Node;
-import pt.up.fe.specs.eclipse.Utilities.EclipseProjects;
-import pt.up.fe.specs.eclipse.Utilities.License;
-import pt.up.fe.specs.eclipse.Utilities.UserLibraries;
-import pt.up.fe.specs.eclipse.builder.BuildResource;
-import pt.up.fe.specs.eclipse.builder.BuildUtils;
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.SpecsLogs;
-import pt.up.fe.specs.util.SpecsXml;
-import pt.up.fe.specs.util.exceptions.NotImplementedException;
-import pt.up.fe.specs.util.lazy.Lazy;
-import pt.up.fe.specs.util.providers.ResourceProvider;
-
-/**
- * @author Joao Bispo
- *
- */
-public class ClasspathParser {
-
- private static final String FILENAME_CLASSPATH = ".classpath";
- private static final String USER_LIBRARY = "org.eclipse.jdt.USER_LIBRARY/";
- private static final String IVY = "org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/";
- private static final String JUNIT4 = "org.eclipse.jdt.junit.JUNIT_CONTAINER/4";
- // private static final String JUNIT5 = "org.eclipse.jdt.junit.JUNIT_CONTAINER/5";
-
- // If true, user libraries declared in a repository will be available to all repositories
- // This is the default behavior in Eclipse, we are replicating it here
- private static final boolean FUSE_USER_LIBRARIES = true;
-
- private static final Set CONTAINERS_TO_IGNORE = new HashSet<>(Arrays.asList(
- // "org.eclipse.jdt.launching.JRE_CONTAINER", "org.eclipse.jdt.junit.JUNIT_CONTAINER"));
- "org.eclipse.jdt.launching.JRE_CONTAINER"));
-
- private final EclipseProjects eclipseProjects;
- private final Map userLibraries;
- private final Lazy fusedUserLibraries = Lazy.newInstance(() -> createFusedUserLibraries());
-
- // TODO: This should be final, but it would need a restructuring of the class
- private File currentProjectFolder = null;
- private List currentSourceFolders;
-
- private final Map classpathCache;
- private final List junitFiles = new ArrayList<>();
-
- /**
- * TODO: This should be the preferred constructor, replace others.
- *
- * @param userLibraries
- * @param eclipseProjects
- */
- // private ClasspathParser(EclipseProjects eclipseProjects, Optional userLibraries) {
- public ClasspathParser(EclipseProjects eclipseProjects, Map userLibraries) {
- currentSourceFolders = new ArrayList<>();
- currentProjectFolder = null;
- this.userLibraries = userLibraries;
- this.eclipseProjects = eclipseProjects;
-
- classpathCache = new HashMap<>();
- }
-
- public static ClasspathParser newInstance(File repositoryFolder) {
- EclipseProjects eclipseProjects = EclipseProjects.newFromRepository(repositoryFolder);
-
- // return new ClasspathParser(eclipseProjects, Optional.empty());
- return new ClasspathParser(eclipseProjects, new HashMap<>());
- }
-
- /**
- * Creates a new ClasspathParser from the folder which contains Eclipse projects, and an exported user libraries
- * file.
- *
- * @param repositoryFolder
- * @param userLibrariesFile
- * @return
- */
- public static ClasspathParser newInstance(File repositoryFolder, File userLibrariesFile) {
-
- // In case user libraries is null
- if (userLibrariesFile == null) {
- return newInstance(repositoryFolder);
- }
-
- EclipseProjects eclipseProjects = EclipseProjects.newFromRepository(repositoryFolder);
-
- UserLibraries repoUserLibraries = UserLibraries.newInstance(eclipseProjects, userLibrariesFile);
- Map userLibraries = new HashMap<>();
- userLibraries.put(repositoryFolder, repoUserLibraries);
-
- return new ClasspathParser(eclipseProjects, userLibraries);
- }
-
- /**
- * Creates a new instance from an Eclipse workspace. By using an Eclipse workspace instead of the folder of a
- * repository (and possibly a user libraries file), it might execute faster by using information already built by
- * Eclipse, instead of building it itself.
- *
- * @param workspaceFolder
- * @return
- */
- public static ClasspathParser newFromWorkspace(File workspaceFolder) {
- return new ClasspathParser(workspaceFolder);
- }
-
- // private ClasspathParser(File workspaceFolder, Optional outputFolder) {
- private ClasspathParser(File workspaceFolder) {
-
- // this.workspaceFolder = workspaceFolder;
- // this.projectName = projectName;
- currentSourceFolders = new ArrayList<>();
- // this.classpathFiles = new HashMap<>();
- /*
- if (outputFolder.isPresent()) {
- File outF = outputFolder.get();
- this.eclipseProjects = EclipseProjects.newFromWorkspace(workspaceFolder).makePathsRelative(outF);
- this.userLibraries = Optional.of(UserLibraries.newInstance(workspaceFolder, eclipseProjects)
- .makePathsRelative(outF));
- } else {
- */
- eclipseProjects = EclipseProjects.newFromWorkspace(workspaceFolder);
- // userLibraries = Optional.of(UserLibraries.newInstance(workspaceFolder, eclipseProjects));
- UserLibraries workspaceUserLibraries = UserLibraries.newInstance(workspaceFolder, eclipseProjects);
- userLibraries = new HashMap<>();
- userLibraries.put(workspaceFolder, workspaceUserLibraries);
-
- classpathCache = new HashMap<>();
- // }
-
- // parseClasspaths();
- }
-
- private UserLibraries createFusedUserLibraries() {
- return UserLibraries.newInstance(userLibraries.values());
- }
-
- /*
- public UserLibraries getUserLibraries() {
- return userLibraries;
- }
- */
-
- /*
- private void parseClasspaths() {
-
- // Map classpathFiles = new HashMap<>();
- for (String projectName : eclipseProjects.getProjectNames()) {
- FilesetBuilder builder = new FilesetBuilder();
-
- parseClasspath(projectName, builder);
-
- ClasspathFiles classpath = builder.newClasspath(projectName, projectFolder, sourceFolders);
-
- classpathFiles.put(projectName, classpath);
- }
-
- // return classpathFiles;
- }
- */
-
- public ClasspathFiles getClasspath(String projectName) {
- /*
- FilesetBuilder builder = new FilesetBuilder();
- parseClasspath(projectName, builder);
-
- return builder.newClasspath(projectName, currentProjectFolder, currentSourceFolders);
- */
- ClasspathFiles files = classpathCache.get(projectName);
- if (files == null) {
- FilesetBuilder builder = new FilesetBuilder(projectName);
- parseClasspath(projectName, builder);
-
- files = builder.newClasspath(projectName, currentProjectFolder, currentSourceFolders);
- classpathCache.put(projectName, files);
- }
-
- return files;
-
- }
-
- public Optional getClasspathTry(String projectName) {
- try {
- return Optional.of(getClasspath(projectName));
- } catch (Exception e) {
- SpecsLogs.msgInfo("Could not get classpath of project '" + projectName + "':" + e.getMessage());
- return Optional.empty();
- }
- }
-
- public boolean usesIvy() {
- for (String projectName : getEclipseProjects().getProjectNames()) {
- if (getClasspath(projectName).getIvyPath().isPresent()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @return the eclipseProjects
- */
- public EclipseProjects getEclipseProjects() {
- return eclipseProjects;
- }
-
- private void parseClasspath(String projectName, FilesetBuilder builder) {
- // System.out.println("-- " + projectName + " --");
-
- List sourceFolders = new ArrayList<>();
-
- File projectFolder = getProjectFolder(projectName);
-
- // Check if builder already parsed this project
- if (builder.hasParsedProject(projectFolder.getPath())) {
- return;
- }
-
- builder.markProjectAsParsed(projectFolder.getPath());
-
- File classpathFile = new File(projectFolder, ClasspathParser.FILENAME_CLASSPATH);
- if (!classpathFile.isFile()) {
- SpecsLogs.msgInfo("Ignoring project '" + projectName + "', could not find classpath file '"
- + ClasspathParser.FILENAME_CLASSPATH + "' in folder '"
- + projectFolder + "'");
- return;
- // throw new RuntimeException("Could not find classpath file '" + FILENAME_CLASSPATH + "' in folder '"
- // + projectFolder + "'");
- }
-
- // Document classpath = XomUtils.getDocument(SpecsIo.read(classpathFile), false);
- // Element classpath = SpecsXml.getXmlRoot(classpathFile).getElementById("classpath");
- Document classpath = SpecsXml.getXmlRoot(classpathFile);
- // Element element = classpath.getRootElement();
- // Element element = classpath.getDocumentElement();
-
- // for (int i = 0; i < element.getChildCount(); i++) {
- // Node child = element.getChild(i);
- // if (!(child instanceof Element)) {
- // continue;
- // }
- // System.out.println("PROJECT: " + projectName);
- // // System.out.println("DOC ELEM: " + classpath.getDocumentElement());
- // System.out.println(
- // "DOC ELEM Children: " + SpecsXml.getElementChildren(classpath.getDocumentElement()));
- // System.out.println(
- // "DOC ELEMs: " + SpecsXml.getElements(classpath.getDocumentElement()));
-
- for (Element childElem : SpecsXml.getElementChildren(classpath.getDocumentElement(), "classpathentry")) {
-
- // if (!childElem.getLocalName().equals("classpathentry")) {
- // SpecsLogs.warn("Entry not parsed:" + childElem.getLocalName());
- // continue;
- // }
-
- // System.out.println("KIND: " + SpecsXml.getAttribute(childElem, "kind"));
-
- // Get 'kind' value
- // Attribute kindAttribute = childElem.getAttribute("kind");
- Attr kindAttribute = childElem.getAttributeNode("kind");
- String kindValue = kindAttribute.getValue();
- // System.out.println("OLD KIND:" + kindValue);
- // Get 'path' value
- // Attribute pathAttribute = childElem.getAttribute("path");
- Attr pathAttribute = childElem.getAttributeNode("path");
- String pathValue = pathAttribute.getValue();
-
- // Attribute accessRulesAttribute = childElem.getAttribute("combineaccessrules");
- Attr accessRulesAttribute = childElem.getAttributeNode("combineaccessrules");
- String accessRulesValue = null;
- if (accessRulesAttribute != null) {
- accessRulesValue = accessRulesAttribute.getValue();
- }
-
- // Get 'exported' value
- // Attribute exportedAttribute = childElem.getAttribute("exported");
- // boolean exported = false;
-
- // if (exportedAttribute != null) {
- // exported = Boolean.parseBoolean(exportedAttribute.getValue());
- // }
-
- // Treat the kind "container"
- if (kindValue.equals("con")) {
-
- // Check if it is one of the containers to ignore
- if (isContainerToIgnore(pathValue)) {
- SpecsLogs.msgLib("Ignoring " + pathValue);
- continue;
- }
-
- // Check if it is a user library
- if (pathValue.startsWith(ClasspathParser.USER_LIBRARY)) {
- UserLibraries projectUserLibraries = getProjectsUserLibraries(projectName);
- // if (!userLibraries.isPresent()) {
- if (projectUserLibraries == null) {
- SpecsLogs
- .warn("In project '"
- + projectName
- + "', found a Eclipse user library reference ('"
- + pathValue
- + "'). To support it, export the user libraries of your Eclipse workspace and pass it as input.");
- continue;
- }
-
- String library = pathValue.substring(ClasspathParser.USER_LIBRARY.length());
- // List jars = userLibraries.get().getJars(library);
- List jars = projectUserLibraries.getJars(library);
- if (jars == null) {
- SpecsLogs.warn("User library '" + library + "' not found, when processing project '"
- + projectName + "'.");
- continue;
- }
-
- builder.addJars(jars);
- continue;
- }
-
- // Check if it is an Ivy library
- if (pathValue.startsWith(ClasspathParser.IVY)) {
-
- // If the builder does not correspond to the project with the Ivy dependency, add transitive Ivy
- // dependency
- if (!projectName.equals(builder.getProjectName())) {
- builder.addProjectWithIvy(projectName);
- continue;
- }
-
- String ivyPath = getIvyPath(pathValue.substring(ClasspathParser.IVY.length()));
- builder.addIvyPath(ivyPath);
- continue;
- }
-
- // Check if it is an Eclipse JUnit
- if (pathValue.startsWith(ClasspathParser.JUNIT4)) {
- // Add Junit
- builder.addJars(getJunitFiles());
- continue;
- }
-
- SpecsLogs.warn("Does not know how to interpret container '" + pathValue + "' in project '"
- + projectName + "', ignoring.");
- continue;
- }
-
- // Treat the kind "src"
- if (kindValue.equals("src")) {
- // Check if it is a src folder of the project
- if (accessRulesValue == null) {
- // Check if path value starts with "/" - can represent a
- // project in older .classpath files
- if (!pathValue.startsWith("/")) {
-
- // Add to sources folder
- sourceFolders.add(pathValue);
- continue;
- }
-
- } else if (accessRulesValue.equals("true")) {
- SpecsLogs.warn("Check if it is correct to ignore '" + pathValue + "'");
- continue;
- }
-
- // Recursively add project to builder
- parseClasspath(pathValue, builder);
- continue;
- }
-
- // Treat the kind "out"
- if (kindValue.equals("output")) {
-
- // Folder might not exist, since project might not have been built yet
- File projectClasses = new File(projectFolder, pathValue);
-
- builder.addProject(projectName, projectClasses);
- }
- }
-
- currentSourceFolders = sourceFolders;
- currentProjectFolder = getProjectFolder(projectName);
-
- }
-
- private UserLibraries getProjectsUserLibraries(String projectName) {
- // Return all libraries, if option to fuse user libraries is enabled
- if (FUSE_USER_LIBRARIES) {
- return fusedUserLibraries.get();
- }
-
- // Check if there is a defined repo
- Optional repoFolder = eclipseProjects.getProjectRepositoryTry(projectName);
-
- if (!repoFolder.isPresent()) {
- // Map of user libraries should have only one value, return that value
- Preconditions.checkArgument(userLibraries.size() == 1,
- "Expected user libraries to have 1 element, it has " + userLibraries.size());
-
- return userLibraries.values().stream().findFirst().get();
- }
-
- // Get corresponding user libraries
- return userLibraries.get(repoFolder.get());
- }
-
- private List getJunitFiles() {
- // Check if files already present
- if (!junitFiles.isEmpty()) {
- return junitFiles;
- }
-
- // Copy junit files
- List junitResources = Arrays.asList(BuildResource.JUNIT, BuildResource.HAMCREST);
-
- junitFiles.addAll(junitResources.stream()
- .map(resource -> SpecsIo.resourceCopy(resource.getResource(), new File("."), false, true))
- .collect(Collectors.toList()));
-
- return junitFiles;
- }
-
- private static String getIvyPath(String ivyValue) {
- String attributeStart = "ivyXmlPath=";
- String attributeEnd = "&";
-
- int startIndex = ivyValue.indexOf(attributeStart);
- if (startIndex == -1) {
- throw new NotImplementedException("Could not find '" + attributeStart
- + "', do not know how to parse the string: " + ivyValue);
- }
-
- String ivyPath = ivyValue.substring(startIndex + attributeStart.length());
-
- int endIndex = ivyPath.indexOf(attributeEnd);
-
- if (endIndex == -1) {
- endIndex = ivyPath.length();
- }
-
- ivyPath = ivyPath.substring(0, endIndex);
-
- return ivyPath;
- }
-
- private File getProjectFolder(String projectName) {
- File projectFolder = eclipseProjects.getProjectFolder(projectName);
-
- String canonicalPath = null;
- try {
- canonicalPath = projectFolder.getCanonicalPath();
- } catch (IOException e) {
- throw new RuntimeException("Could not get canonical path for '" + canonicalPath + "'", e);
- }
-
- // Now use canonical path
- canonicalPath = canonicalPath.replace('\\', '/');
- currentProjectFolder = new File(canonicalPath);
- return currentProjectFolder;
- }
-
- /**
- * @param pathValue
- * @return
- */
- private static boolean isContainerToIgnore(String pathValue) {
- // Just check container until first '/'
- int index = pathValue.indexOf('/');
- if (index != -1) {
- pathValue = pathValue.substring(0, index);
- }
-
- return ClasspathParser.CONTAINERS_TO_IGNORE.contains(pathValue);
- /*
- * for(String containersToIgnore : CONTAINERS_TO_IGNORE) {
- * if(pathValue.startsWith(containersToIgnore)) { return true; } }
- *
- * return false;
- */
- }
-
- /**
- * Returns a list of all Eclipse projects the given project depends on.
- *
- *
- * The search is done recursively.
- *
- * @param projectName
- * @return
- */
- public Collection getDependentProjects(String projectName) {
- Set projects = new HashSet<>();
-
- getDependentProjects(projectName, projects);
-
- return projects;
- }
-
- public Collection getDependentProjectsAndSelf(String projectName) {
- Set projects = new HashSet<>();
- projects.add(projectName);
- projects.addAll(getDependentProjects(projectName));
- return projects;
- }
-
- /**
- * Recursive helper method which does all the work.
- *
- * @param projectName
- * @param projects
- * @return
- */
- private void getDependentProjects(String projectName, Set projects) {
- // If project already on the set, ignore
- if (projects.contains(projectName)) {
- return;
- }
-
- // Add self
- projects.add(projectName);
-
- // Add all dependencies of the project
- for (String dependentProject : getClasspath(projectName).getDependentProjects()) {
- getDependentProjects(dependentProject, projects);
- }
- }
-
- public Set getLicenses(String projetName) {
- // Get all project folders
- List projectFolders = new ArrayList<>();
-
- // Add self
- projectFolders.add(getClasspath(projetName).getProjectFolder());
-
- // Gather all git repositories of current projects
- for (String dependentProject : getClasspath(projetName).getDependentProjects()) {
- projectFolders.add(getClasspath(dependentProject).getProjectFolder());
- }
-
- Set licenses = EnumSet.noneOf(License.class);
-
- // Find the license of each project
- for (File projectFolder : projectFolders) {
- // System.out.println("CHECKING LICENSE OF " + projectFolder);
-
- File currentFolder = projectFolder;
- License currentLicense = null;
- while (currentFolder != null) {
- File licenseFile = new File(currentFolder, "LICENSE");
- if (licenseFile.isFile()) {
- currentLicense = License.valueOf(licenseFile);
- break;
- }
-
- currentFolder = currentFolder.getParentFile();
- }
-
- if (currentLicense == null) {
- throw new RuntimeException("Could not find a license for project at " + projectFolder);
- }
-
- licenses.add(currentLicense);
- }
-
- return licenses;
- }
-
- public Set getIvyDependencies(String projectName) {
- Set dependencies = new HashSet<>();
-
- for (String dependentProject : getDependentProjectsAndSelf(projectName)) {
- getClasspath(dependentProject).getIvyFile()
- .map(this::getIvyDependencies)
- .ifPresent(dependencies::addAll);
- }
-
- return dependencies;
- }
-
- public Collection getIvyDependencies(File ivyFile) {
- Set dependencies = new HashSet<>();
-
- Document ivyXml = SpecsXml.getXmlRoot(ivyFile);
- List ivyDependencies = SpecsXml.getElements(ivyXml.getDocumentElement(), "dependency");
-
- for (Element ivyDependency : ivyDependencies) {
- Dependency newDependency = new Dependency();
- newDependency.set(Dependency.GROUP, ivyDependency.getAttribute("org"));
- newDependency.set(Dependency.NAME, ivyDependency.getAttribute("name"));
- newDependency.set(Dependency.VERSION, ivyDependency.getAttribute("rev"));
-
- dependencies.add(newDependency);
- }
-
- return dependencies;
- }
-
- public void cleanIvyFolders(String rootProjectName) {
-
- var projects = getEclipseProjects();
-
- var projectNames = getDependentProjectsAndSelf(rootProjectName);
-
- SpecsLogs.info("Cleaning ivy folders of potentially " + projectNames.size()
- + " projects (some projects might not have ivy folders)");
-
- var counter = 0;
- for (var projectName : projectNames) {
-
- var ivyFolder = BuildUtils.getIvyJarFolder(projects.getProjectFolder(projectName));
-
- // If not a directory, ignore
- if (!ivyFolder.isDirectory()) {
- SpecsLogs.info("Skipping " + projectName);
- continue;
- }
-
- // Clean folder contents
- SpecsLogs.info("Cleaning " + projectName);
- SpecsIo.deleteFolderContents(ivyFolder);
- counter++;
- }
-
- if (counter == 0) {
- SpecsLogs.info("Did not find 'ivy' folders to clean");
- } else {
- SpecsLogs.info("Cleaned " + counter + " 'ivy' folders");
- }
-
- }
-
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/Dependency.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/Dependency.java
deleted file mode 100644
index ea92eb28..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/Dependency.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.Classpath;
-
-import org.suikasoft.jOptions.DataStore.ADataClass;
-import org.suikasoft.jOptions.Datakey.DataKey;
-import org.suikasoft.jOptions.Datakey.KeyFactory;
-
-/**
- * Represents a dependency.
- *
- * @author JoaoBispo
- *
- */
-public class Dependency extends ADataClass {
-
- public static final DataKey GROUP = KeyFactory.string("group");
- public static final DataKey NAME = KeyFactory.string("name");
- public static final DataKey VERSION = KeyFactory.string("version");
-
- public String toMaven() {
- return "\n" +
- " " + get(GROUP) + "\n" +
- " " + get(NAME) + "\n" +
- " " + get(VERSION) + "\n" +
- "";
- }
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/FilesetBuilder.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/FilesetBuilder.java
deleted file mode 100644
index 6ecda12e..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/Classpath/FilesetBuilder.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse.Classpath;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import pt.up.fe.specs.util.SpecsFactory;
-
-/**
- * @author Joao Bispo
- *
- */
-public class FilesetBuilder {
-
- private final Set parsedProjects;
-
- private final Map projectFolders;
- private final Set jarFiles;
- private Optional ivyPath;
- private final Set projectsWithIvy;
-
- private final String projectName;
-
- public FilesetBuilder(String projectName) {
- this.projectName = projectName;
-
- parsedProjects = new HashSet<>();
- projectFolders = new LinkedHashMap<>();
- jarFiles = new LinkedHashSet<>();
- ivyPath = Optional.empty();
- projectsWithIvy = new HashSet<>();
- }
-
- /**
- * @param projectName
- * @param projectFolder
- * @param sourceFolders
- * @return
- */
- public ClasspathFiles newClasspath(String projectName, File projectFolder, List sourceFolders) {
- // Check if project has a commands file
- File commandsFile = new File(projectFolder, ClasspathFiles.getCommandsFilename());
- commandsFile = commandsFile.isFile() ? commandsFile : null;
-
- return new ClasspathFiles(projectName, projectFolder, sourceFolders, SpecsFactory.newHashMap(projectFolders),
- new ArrayList<>(jarFiles), ivyPath, new ArrayList<>(projectsWithIvy), commandsFile);
- }
-
- public String getProjectName() {
- return projectName;
- }
-
- /**
- * @param projectName
- * @return
- */
- public boolean hasParsedProject(String projectName) {
- return parsedProjects.contains(projectName);
- }
-
- /**
- * @param projectName
- */
- public void markProjectAsParsed(String projectName) {
- parsedProjects.add(projectName);
- }
-
- /**
- * @param jars
- */
- public void addJars(List jars) {
- jarFiles.addAll(jars);
- }
-
- /**
- * @param projectName
- * @param projectFolder
- */
- public void addProject(String projectName, File projectFolder) {
- projectFolders.put(projectName, projectFolder);
- }
-
- public void addIvyPath(String ivyPath) {
- this.ivyPath = Optional.of(ivyPath);
- }
-
- public void addProjectWithIvy(String projectName) {
- projectsWithIvy.add(projectName);
- }
-
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/DeployResource.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/DeployResource.java
deleted file mode 100644
index ecb25656..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/DeployResource.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse;
-
-import pt.up.fe.specs.util.providers.ResourceProvider;
-
-/**
- * @author Joao Bispo
- *
- */
-public enum DeployResource implements ResourceProvider {
-
- DEPLOY_SUBFOLDER_ZIP_TEMPLATE("deploy/deploy_subfolder_zip.xml.template"),
- DEPLOY_ONE_JAR_TEMPLATE("deploy/deploy_onejar.xml.template"),
- DEPLOY_JAR_IN_JAR_TEMPLATE("deploy.xml.template"),
- DEPLOY_REPACK_TEMPLATE("deploy/deploy_repack.xml.template"),
- DEPLOY_MAVEN_REPOSITORY_TEMPLATE("deploy/deploy_maven_repo.xml.template"),
- DEPLOY_POM_TEMPLATE("deploy/deploy_pom.xml.template"),
- DEPLOY_MAVEN_SCRIPT_TEMPLATE("deploy/deploy_maven_script.bat.template"),
- IVY_RESOLVE_TEMPLATE("resolveIvy.xml.template"),
- SFTP_TEMPLATE("sftp.xml.template"),
- FTP_TEMPLATE("ftp.xml.template"),
- JAR_IN_JAR_LOADER("jar-in-jar-loader.zip");
-
- private final String resource;
-
- private DeployResource(String resource) {
- this.resource = resource;
- }
-
- /* (non-Javadoc)
- * @see pt.up.fe.specs.util.Interfaces.ResourceProvider#getResource()
- */
- @Override
- public String getResource() {
- return resource;
- }
-
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeployment.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeployment.java
deleted file mode 100644
index 8dd27671..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeployment.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-
-import pt.up.fe.specs.eclipse.Classpath.ClasspathFiles;
-import pt.up.fe.specs.eclipse.Classpath.ClasspathParser;
-import pt.up.fe.specs.eclipse.Tasks.TaskExecutor;
-import pt.up.fe.specs.eclipse.Tasks.TaskUtils;
-import pt.up.fe.specs.eclipse.Utilities.DeployUtils;
-import pt.up.fe.specs.eclipse.Utilities.PostProcessUtils;
-import pt.up.fe.specs.eclipse.builder.BuildUtils;
-import pt.up.fe.specs.guihelper.BaseTypes.SetupData;
-import pt.up.fe.specs.lang.SpecsPlatforms;
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.SpecsLogs;
-import pt.up.fe.specs.util.SpecsSystem;
-import pt.up.fe.specs.util.utilities.ProgressCounter;
-import pt.up.fe.specs.util.utilities.Replacer;
-
-/**
- * Builds and deploys Eclipse projects.
- *
- * @author Joao Bispo
- */
-public class EclipseDeployment {
-
- private static final String BUILD_FILE = "build.xml";
-
- private static final Map tasks = TaskUtils.getTasksByName();
-
- private static final Map> DEPLOY_BUILDER;
- static {
- DEPLOY_BUILDER = new HashMap<>();
- EclipseDeployment.DEPLOY_BUILDER.put(JarType.SubfolderZip, EclipseDeployment::buildSubfolderZip);
- EclipseDeployment.DEPLOY_BUILDER.put(JarType.OneJar, EclipseDeployment::buildOneJar);
- EclipseDeployment.DEPLOY_BUILDER.put(JarType.RepackJar, EclipseDeployment::buildJarRepack);
- EclipseDeployment.DEPLOY_BUILDER.put(JarType.UseJarInJar, EclipseDeployment::buildJarInJar);
- EclipseDeployment.DEPLOY_BUILDER.put(JarType.MavenRepository, EclipseDeployment::buildMavenRepository);
- }
-
- private final EclipseDeploymentData data;
- // private final Map taskMap;
-
- public EclipseDeployment(EclipseDeploymentData data) {
- this.data = data;
- // this.taskMap = buildTasks();
- }
-
- // private Map buildTasks() {
- // // TODO Auto-generated method stub
- // return null;
- // }
-
- public int execute() {
-
- // Clear temporary folder
- DeployUtils.clearTempFolder();
-
- // Resolve Ivy
- resolveIvy();
-
- // Check if case is defined
- if (!EclipseDeployment.DEPLOY_BUILDER.containsKey(data.jarType)) {
- SpecsLogs.warn("Case not defined:" + data.jarType);
- }
-
- // Build JAR
- EclipseDeployment.DEPLOY_BUILDER
- .getOrDefault(data.jarType, EclipseDeployment::buildJarRepack)
- .accept(data);
-
- if (data.processJar) {
- PostProcessUtils.processBuiltFile(data.getResultFile());
- }
-
- // Execute tasks
- processTasks();
-
- return 0;
- }
-
- private void resolveIvy() {
- ClasspathParser parser = ClasspathParser.newFromWorkspace(data.workspaceFolder);
-
- Collection dependentProjects = parser.getDependentProjects(data.projetName);
- Collection projectsWithIvy = BuildUtils.filterProjectsWithIvy(parser, dependentProjects);
-
- // Replace fields in template
- String template = SpecsIo.getResource(DeployResource.IVY_RESOLVE_TEMPLATE);
-
- // System.out.println("IVY RESOLVE 1:\n" + BuildUtils.getResolveTasks(parser, dependentProjects));
- // System.out.println("IVY RESOLVE 2:\n" + BuildUtils.getResolveTask(classpathFiles));
- template = template.replace("", BuildUtils.getResolveTasks(parser, dependentProjects));
- template = template.replace("", BuildUtils.getIvyDependency(parser));
- template = template.replace("", BuildUtils.getIvyDepends(projectsWithIvy));
- // System.out.println("BUILD FILE:\n" + template);
-
- // Save script
- File buildFile = new File(EclipseDeployment.BUILD_FILE);
- SpecsIo.write(buildFile, template);
-
- // Launch ant
- Project project = new Project();
- project.init();
-
- ProjectHelper.configureProject(project, buildFile);
-
- project.addBuildListener(DeployUtils.newStdoutListener());
- project.executeTarget(project.getDefaultTarget());
-
- }
-
- /**
- *
- */
- public void processTasks() {
-
- ProgressCounter progress = new ProgressCounter(data.tasks.getNumSetups());
-
- for (SetupData setup : data.tasks.getMapOfSetups()) {
- String setupName = setup.getSetupName();
-
- System.out.println("Executing task '" + setupName + "' " + progress.next());
-
- // Get task
- TaskExecutor task = EclipseDeployment.tasks.get(setupName);
-
- if (task == null) {
- SpecsLogs.warn("Could not find task for setup '" + setupName + "', available names: "
- + EclipseDeployment.tasks.keySet());
- continue;
- }
-
- task.execute(setup, data);
- }
-
- }
-
- /**
- *
- */
- /*
- private void deployFtp() {
- String script = "open specsuser:SpecS#12345@specs.fe.up.pt\r\n" + "bin\r\n"
- + "cd /home/specsuser/tools/gearman_server\r\n" + "put C:\\temp_output\\deploy\\suika.properties\r\n"
- + "ls\r\n" + "exit";
-
- IoUtils.write(new File("ftp_script.txt"), script);
-
- ProcessUtils.run(Arrays.asList("WinSCP.com", "/script=ftp_script.txt"), IoUtils.getWorkingDir()
- .getAbsolutePath());
-
- }
- */
-
- /**
- * Builds a JAR with additional library JARs inside. Uses a custom class loader.
- */
- private static void buildJarInJar(EclipseDeploymentData data) {
- ClasspathParser parser = ClasspathParser.newFromWorkspace(data.workspaceFolder);
-
- ClasspathFiles classpathFiles = parser.getClasspath(data.projetName);
-
- Collection dependentProjects = parser.getDependentProjects(data.projetName);
- Collection projectsWithIvy = BuildUtils.filterProjectsWithIvy(parser, dependentProjects);
- Collection ivyFolders = projectsWithIvy.stream()
- .map(ivyProject -> BuildUtils.getIvyJarFoldername(parser.getClasspath(ivyProject).getProjectFolder()))
- .collect(Collectors.toList());
-
- String fileset = DeployUtils.buildFileset(parser, data.projetName, ivyFolders, false);
-
- String jarList = DeployUtils.buildJarList(classpathFiles, ivyFolders);
-
- // Replace fields in template
- String template = SpecsIo.getResource(DeployResource.DEPLOY_JAR_IN_JAR_TEMPLATE);
-
- // Output JAR
- File outputJar = DeployUtils.getOutputJar(data);
-
- template = template.replace("", outputJar.getAbsolutePath());
- template = template.replace("", data.mainClass);
- template = template.replace("", jarList);
- template = template.replace("", fileset);
-
- // System.out.println("IVY RESOLVE 1:\n" + BuildUtils.getResolveTasks(parser, dependentProjects));
- // System.out.println("IVY RESOLVE 2:\n" + BuildUtils.getResolveTask(classpathFiles));
- template = template.replace("", BuildUtils.getResolveTasks(parser, dependentProjects));
- template = template.replace("", BuildUtils.getIvyDependency(parser));
- template = template.replace("", BuildUtils.getIvyDepends(projectsWithIvy));
- template = template.replace("", DeployUtils.getDeleteIvyFolders(ivyFolders));
- // System.out.println("BUILD FILE:\n" + template);
- // Save script
- File buildFile = new File(EclipseDeployment.BUILD_FILE);
- SpecsIo.write(buildFile, template);
-
- // Run script
- // ProcessUtils.run(Arrays.asList("ant", "build.xml"), IoUtils.getWorkingDir().getPath());
- // Launch ant
- Project project = new Project();
- project.init();
-
- ProjectHelper.configureProject(project, buildFile);
-
- project.addBuildListener(DeployUtils.newStdoutListener());
- project.executeTarget(project.getDefaultTarget());
- // System.out.println("OUTPUT JAR:" + outputJar.getAbsolutePath());
- // Check if jar file exists
- if (!outputJar.isFile()) {
- throw new RuntimeException("Could not create output JAR '" + outputJar.getAbsolutePath() + "'");
- }
-
- }
-
- /**
- * Creates a single JAR with additional library JARs extracted into the file.
- */
- private static void buildJarRepack(EclipseDeploymentData data) {
- ClasspathParser parser = ClasspathParser.newFromWorkspace(data.workspaceFolder);
-
- ClasspathFiles classpathFiles = parser.getClasspath(data.projetName);
-
- Collection dependentProjects = parser.getDependentProjects(data.projetName);
- Collection projectsWithIvy = BuildUtils.filterProjectsWithIvy(parser, dependentProjects);
- Collection ivyFolders = projectsWithIvy.stream()
- .map(ivyProject -> BuildUtils.getIvyJarFoldername(parser.getClasspath(ivyProject).getProjectFolder()))
- .collect(Collectors.toList());
-
- String fileset = DeployUtils.buildFileset(parser, data.projetName, ivyFolders, true);
- String jarList = DeployUtils.buildJarList(classpathFiles, ivyFolders);
-
- // Replace fields in template
- String template = SpecsIo.getResource(DeployResource.DEPLOY_REPACK_TEMPLATE);
-
- // Output JAR
- File outputJar = DeployUtils.getOutputJar(data);
-
- template = template.replace("", outputJar.getAbsolutePath());
- template = template.replace("", data.mainClass);
- template = template.replace("", jarList);
- template = template.replace("", fileset);
-
- // System.out.println("IVY RESOLVE 1:\n" + BuildUtils.getResolveTasks(parser, dependentProjects));
- // System.out.println("IVY RESOLVE 2:\n" + BuildUtils.getResolveTask(classpathFiles));
- template = template.replace("", BuildUtils.getResolveTasks(parser, dependentProjects));
- template = template.replace("", BuildUtils.getIvyDependency(parser));
- template = template.replace("", BuildUtils.getIvyDepends(projectsWithIvy));
- template = template.replace("", DeployUtils.getDeleteIvyFolders(ivyFolders));
- template = template.replace("", SpecsSystem.getBuildNumberAttr());
- template = template.replace("", data.getBuildNumber());
-
- // System.out.println("BUILD FILE:\n" + template);
- // Save script
- File buildFile = new File(EclipseDeployment.BUILD_FILE);
- SpecsIo.write(buildFile, template);
-
- // Run script
- // ProcessUtils.run(Arrays.asList("ant", "build.xml"), IoUtils.getWorkingDir().getPath());
- // Launch ant
- Project project = new Project();
- project.init();
-
- ProjectHelper.configureProject(project, buildFile);
-
- project.addBuildListener(DeployUtils.newStdoutListener());
- project.executeTarget(project.getDefaultTarget());
- // System.out.println("OUTPUT JAR:" + outputJar.getAbsolutePath());
- // Check if jar file exists
- if (!outputJar.isFile()) {
- throw new RuntimeException("Could not create output JAR '" + outputJar.getAbsolutePath() + "'");
- }
-
- }
-
- // Creates a JAR file with additional library JARs inside a folder. Optionally, zips the JAR file and folders.
- // private static void buildSubfolderZip(EclipseDeploymentData data, boolean zip) {
-
- /**
- * Creates a zip file with a JAR and additional library JARs inside a folder.
- */
- private static void buildSubfolderZip(EclipseDeploymentData data) {
-
- ClasspathParser parser = ClasspathParser.newFromWorkspace(data.workspaceFolder);
-
- ClasspathFiles classpathFiles = parser.getClasspath(data.projetName);
-
- Collection dependentProjects = parser.getDependentProjects(data.projetName);
- Collection projectsWithIvy = BuildUtils.filterProjectsWithIvy(parser, dependentProjects);
- Collection ivyFolders = projectsWithIvy.stream()
- .map(ivyProject -> BuildUtils.getIvyJarFoldername(parser.getClasspath(ivyProject).getProjectFolder()))
- .collect(Collectors.toList());
-
- String mainFileset = DeployUtils.buildMainFileset(parser, data.projetName);
- // String jarList = DeployUtils.buildJarList(classpathFiles, ivyFolders);
-
- // Replace fields in template
- String template = SpecsIo.getResource(DeployResource.DEPLOY_SUBFOLDER_ZIP_TEMPLATE);
-
- // Output JAR
- File outputJar = DeployUtils.getOutputJar(data);
- String outputJarname = outputJar.getName();
- String outputJarFoldername = outputJar.getParent();
- String libFoldername = data.projetName + "_lib";
-
- List jarFileList = DeployUtils.getJarFiles(classpathFiles.getJarFiles(), ivyFolders, false);
-
- String jarList = jarFileList.stream()
- .map(jarFile -> libFoldername + "/" + jarFile.getName())
- .collect(Collectors.joining(" "));
-
- String jarZipfileset = DeployUtils.buildJarZipfileset(jarFileList, libFoldername);
-
- // Output Zip
- File outputZip = new File(outputJar.getParentFile(), SpecsIo.removeExtension(outputJar) + ".zip");
-
- // Set output file as being the zip
- data.setResultFile(outputZip);
-
- template = template.replace("", outputJar.getAbsolutePath());
- template = template.replace("", outputJarFoldername);
- template = template.replace("", outputJarname);
- template = template.replace("", outputZip.getAbsolutePath());
- template = template.replace("", data.mainClass);
- template = template.replace("", jarList);
- template = template.replace("", mainFileset);
- template = template.replace("", jarZipfileset);
- template = template.replace("", SpecsSystem.getBuildNumberAttr());
- template = template.replace("", data.getBuildNumber());
-
- // System.out.println("IVY RESOLVE 1:\n" + BuildUtils.getResolveTasks(parser, dependentProjects));
- // System.out.println("IVY RESOLVE 2:\n" + BuildUtils.getResolveTask(classpathFiles));
- template = template.replace("", BuildUtils.getResolveTasks(parser, dependentProjects));
- template = template.replace("", BuildUtils.getIvyDependency(parser));
- template = template.replace("", BuildUtils.getIvyDepends(projectsWithIvy));
- template = template.replace("", DeployUtils.getDeleteIvyFolders(ivyFolders));
- // System.out.println("BUILD FILE:\n" + template);
- // Save script
- File buildFile = new File(EclipseDeployment.BUILD_FILE);
- SpecsIo.write(buildFile, template);
-
- // Run script
- // ProcessUtils.run(Arrays.asList("ant", "build.xml"), IoUtils.getWorkingDir().getPath());
- // Launch ant
- Project project = new Project();
- project.init();
-
- ProjectHelper.configureProject(project, buildFile);
-
- project.addBuildListener(DeployUtils.newStdoutListener());
- project.executeTarget(project.getDefaultTarget());
- // System.out.println("OUTPUT JAR:" + outputJar.getAbsolutePath());
- // Check if jar file exists
- if (!outputJar.isFile()) {
- throw new RuntimeException("Could not create output JAR '" + outputJar.getAbsolutePath() + "'");
- }
-
- }
-
- /**
- * Creates the necessary JAR files to deploy to Maven Repository.
- */
- private static void buildMavenRepository(EclipseDeploymentData data) {
-
- ClasspathParser parser = ClasspathParser.newFromWorkspace(data.workspaceFolder);
-
- ClasspathFiles classpathFiles = parser.getClasspath(data.projetName);
-
- Collection dependentProjects = parser.getDependentProjects(data.projetName);
- Collection projectsWithIvy = BuildUtils.filterProjectsWithIvy(parser, dependentProjects);
- Collection ivyFolders = projectsWithIvy.stream()
- .map(ivyProject -> BuildUtils.getIvyJarFoldername(parser.getClasspath(ivyProject).getProjectFolder()))
- .collect(Collectors.toList());
-
- // String fileset = DeployUtils.buildFileset(parser, data.projetName, ivyFolders, false);
-
- // String jarList = DeployUtils.buildJarList(classpathFiles, ivyFolders);
-
- // Output JAR
- File outputJar = DeployUtils.getOutputJar(data);
-
- // Subfolder name
- String subFoldername = "libs";
-
- List ivyJars = DeployUtils.getJarFiles(Collections.emptyList(), ivyFolders, true);
-
- // Subfolder gets Ivy JARs
- String subfolderJars = ivyJars.stream()
- .map(file -> subFoldername + "/" + file.getName())
- .collect(Collectors.joining(" "));
-
- String fileset = DeployUtils.buildProjectsFileset(parser, data.projetName).stream()
- .collect(Collectors.joining("\n" + DeployUtils.getPrefix(), DeployUtils.getPrefix(), ""));
-
- // Project JARs are repackaged inside JAR
- List projectsJars = DeployUtils.getJarFiles(classpathFiles.getJarFiles(), Collections.emptyList(), true);
-
- if (!projectsJars.isEmpty()) {
- SpecsLogs.debug(() -> "Repackaging the following JARs in SubFolder deploy: " + projectsJars);
-
- for (var jarFile : projectsJars) {
- String line = DeployUtils.getZipfilesetExtracted(jarFile);
- fileset += "\n" + DeployUtils.getPrefix() + line;
- }
-
- }
-
- // Subfolder
- File subfolder = new File(DeployUtils.getTempFolder(), subFoldername);
-
- String copyJars = ivyJars.stream()
- .map(jar -> DeployUtils.getCopyTask(jar, subfolder))
- .collect(Collectors.joining("\n"));
-
- // Sources
-
- File sourcesJar = DeployUtils.getJarWithClassifier(data.nameOfOutputJar, "sources");
-
- String sourcesFileset = DeployUtils.buildSourcesFileset(parser, data.projetName).stream()
- .collect(Collectors.joining("\n" + DeployUtils.getPrefix()));
-
- // Javadoc
- File javadocFolder = new File(DeployUtils.getTempFolder(), "javadoc");
- File javadocJar = DeployUtils.getJarWithClassifier(data.nameOfOutputJar, "javadoc");
-
- List allJars = new ArrayList<>();
- allJars.addAll(projectsJars);
- allJars.addAll(ivyJars);
- String javadocClasspath = allJars.stream()
- .map(file -> SpecsIo.normalizePath(file.getAbsoluteFile()))
- .collect(Collectors.joining(":"));
- // String javadocClasspath = ivyJars.stream()
- // .map(file -> SpecsIo.normalizePath(new File(subfolder, file.getName())))
- // .collect(Collectors.joining(":"));
-
- // POM file
- String mavenPom = DeployUtils.buildMavenRepoPom(data, parser);
- File pomFile = DeployUtils.getFileWithClassifier(data.nameOfOutputJar, null, "pom");
- SpecsIo.write(pomFile, mavenPom);
-
- // Replace fields in template
- String template = SpecsIo.getResource(DeployResource.DEPLOY_MAVEN_REPOSITORY_TEMPLATE);
-
- template = template.replace("", outputJar.getAbsolutePath());
- template = template.replace("", data.mainClass);
- template = template.replace("", subfolderJars);
- template = template.replace("", fileset);
- template = template.replace("", subfolder.getAbsolutePath());
- template = template.replace("", copyJars);
- template = template.replace("", sourcesJar.getAbsolutePath());
- template = template.replace("", sourcesFileset);
- template = template.replace("", javadocFolder.getAbsolutePath());
- template = template.replace("", javadocJar.getAbsolutePath());
- template = template.replace("", javadocClasspath);
-
- File buildFile = new File(EclipseDeployment.BUILD_FILE);
- SpecsIo.write(buildFile, template);
-
- // Launch ant
- Project project = new Project();
- project.init();
-
- ProjectHelper.configureProject(project, buildFile);
-
- project.addBuildListener(DeployUtils.newStdoutListener());
- project.executeTarget(project.getDefaultTarget());
-
- // Check if jar file exists
- if (!outputJar.isFile()) {
- throw new RuntimeException("Could not create output JAR '" + outputJar.getAbsolutePath() + "'");
- }
-
- // Create script
- Replacer deployScript = new Replacer(DeployResource.DEPLOY_MAVEN_SCRIPT_TEMPLATE);
- deployScript.replace("%POM_FILE%", pomFile.getName());
- deployScript.replace("%JAR_FILE%", outputJar.getName());
- deployScript.replace("%SOURCE_FILE%", sourcesJar.getName());
- deployScript.replace("%JAVADOC_FILE%", javadocJar.getName());
-
- String scriptExtension = SpecsPlatforms.isWindows() ? ".bat" : ".sh";
-
- File scriptFile = new File(DeployUtils.getTempFolder(), "deploy_script" + scriptExtension);
- SpecsIo.write(scriptFile, deployScript.toString());
-
- SpecsLogs.msgInfo(
- "Artifacts generated, to deploy them execute the script '" + scriptFile.getAbsolutePath() + "'");
-
- }
-
- /**
- * Builds a JAR with additional library JARs inside, using Simon Tuffs One-JAR.
- */
- private static void buildOneJar(EclipseDeploymentData data) {
- ClasspathParser parser = ClasspathParser.newFromWorkspace(data.workspaceFolder);
-
- ClasspathFiles classpathFiles = parser.getClasspath(data.projetName);
-
- Collection dependentProjects = parser.getDependentProjects(data.projetName);
- Collection projectsWithIvy = BuildUtils.filterProjectsWithIvy(parser, dependentProjects);
- Collection ivyFolders = projectsWithIvy.stream()
- .map(ivyProject -> BuildUtils.getIvyJarFoldername(parser.getClasspath(ivyProject).getProjectFolder()))
- .collect(Collectors.toList());
-
- String mainFileset = DeployUtils.buildMainFileset(parser, data.projetName);
- String libFileset = DeployUtils.buildLibFileset(parser, data.projetName, ivyFolders);
-
- String jarList = DeployUtils.buildJarList(classpathFiles, ivyFolders);
-
- // Replace fields in template
- String template = SpecsIo.getResource(DeployResource.DEPLOY_ONE_JAR_TEMPLATE);
-
- // Output JAR
- File outputJar = DeployUtils.getOutputJar(data);
-
- template = template.replace("", outputJar.getAbsolutePath());
- template = template.replace("", data.mainClass);
- template = template.replace("", jarList);
- template = template.replace("", mainFileset);
- template = template.replace("", libFileset);
-
- template = template.replace("", BuildUtils.getResolveTasks(parser, dependentProjects));
- template = template.replace("", BuildUtils.getIvyDependency(parser));
- template = template.replace("", BuildUtils.getIvyDepends(projectsWithIvy));
- template = template.replace("", DeployUtils.getDeleteIvyFolders(ivyFolders));
-
- // Save script
- File buildFile = new File(EclipseDeployment.BUILD_FILE);
- SpecsIo.write(buildFile, template);
- System.out.println("BUILD.XML:\n" + template);
- // Run script
- // ProcessUtils.run(Arrays.asList("ant", "build.xml"), IoUtils.getWorkingDir().getPath());
- // Launch ant
- Project project = new Project();
- project.init();
-
- ProjectHelper.configureProject(project, buildFile);
-
- project.addBuildListener(DeployUtils.newStdoutListener());
- project.executeTarget(project.getDefaultTarget());
- // System.out.println("OUTPUT JAR:" + outputJar.getAbsolutePath());
- // Check if jar file exists
- if (!outputJar.isFile()) {
- throw new RuntimeException("Could not create output JAR '" + outputJar.getAbsolutePath() + "'");
- }
-
- }
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentData.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentData.java
deleted file mode 100644
index 704036dc..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentData.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse;
-
-import java.io.File;
-
-import pt.up.fe.specs.guihelper.BaseTypes.ListOfSetups;
-import pt.up.fe.specs.util.SpecsSystem;
-import pt.up.fe.specs.util.properties.SpecsProperties;
-
-/**
- * Data fields for EclipseDeployment.
- *
- * @author Joao Bispo
- */
-public class EclipseDeploymentData {
-
- public final File workspaceFolder;
- public final String projetName;
- public final String nameOfOutputJar;
- public final String mainClass;
- public final JarType jarType;
- public final SpecsProperties pomInfo;
- public final File developersXml;
- public final String version;
- public final boolean processJar; // Removes \r from manifest file
- public final ListOfSetups tasks;
-
- private File resultFile;
- private final String buildNumber;
-
- public EclipseDeploymentData(File workspaceFolder, String projetName, String nameOfOutputJar, String mainClass,
- JarType jarType, SpecsProperties pomInfo, File developersXml, String version, boolean processJar,
- ListOfSetups tasks) {
-
- this.workspaceFolder = workspaceFolder;
- this.projetName = projetName;
- this.nameOfOutputJar = nameOfOutputJar;
- this.mainClass = mainClass;
- this.jarType = jarType;
- this.pomInfo = pomInfo;
- this.developersXml = developersXml;
- this.version = version;
- this.processJar = processJar;
- this.tasks = tasks;
- this.resultFile = null;
- this.buildNumber = SpecsSystem.createBuildNumber();
- }
-
- public void setResultFile(File resultFile) {
- this.resultFile = resultFile;
- }
-
- public File getResultFile() {
- return resultFile;
- }
-
- public String getBuildNumber() {
- return buildNumber;
- }
-}
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentLauncher.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentLauncher.java
deleted file mode 100644
index 79a64a42..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentLauncher.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import pt.up.fe.specs.guihelper.App;
-import pt.up.fe.specs.guihelper.AppDefaultConfig;
-import pt.up.fe.specs.guihelper.AppSource;
-import pt.up.fe.specs.guihelper.GuiHelperUtils;
-import pt.up.fe.specs.guihelper.Base.SetupDefinition;
-import pt.up.fe.specs.guihelper.BaseTypes.SetupData;
-import pt.up.fe.specs.guihelper.gui.SimpleGui;
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.SpecsLogs;
-import pt.up.fe.specs.util.SpecsSystem;
-import pt.up.fe.specs.util.properties.SpecsProperty;
-
-/**
- * Launches the program EclipseDeployment.
- *
- * @author Joao Bispo
- */
-public class EclipseDeploymentLauncher implements AppDefaultConfig, AppSource {
-
- /**
- * @param args
- * the command line arguments
- */
- public static void main(String[] args) {
- SpecsSystem.programStandardInit();
-
- SpecsIo.resourceCopy(getResources());
-
- EclipseDeploymentLauncher app = new EclipseDeploymentLauncher();
-
- if (args.length > 0) {
- GuiHelperUtils.trySingleConfigMode(args, app);
- return;
- }
-
- SimpleGui gui = new SimpleGui(app);
-
- gui.setTitle("EclipseDeployment v0.1");
- gui.execute();
- }
-
- public static List getResources() {
- List resources = new ArrayList<>();
- resources.addAll(baseResourceFiles);
- resources.addAll(SpecsProperty.getResources());
- return resources;
- }
-
- @Override
- public int execute(File setupFile) throws InterruptedException {
- SetupData setupData = GuiHelperUtils.loadData(setupFile);
-
- // EclipseDeploymentGlobalData globalData = EclipseDeploymentGlobalSetup.getData();
-
- EclipseDeploymentData data = null;
- try {
- data = EclipseDeploymentSetup.newData(setupData);
- } catch (Exception e) {
- SpecsLogs.warn("Exception while building configuration data.", e);
- return -1;
- }
-
- if (data == null) {
- SpecsLogs.warn("Configuration data is null.");
- return -1;
- }
-
- EclipseDeployment appBody = new EclipseDeployment(data);
-
- int result = appBody.execute();
- SpecsLogs.msgInfo("Done");
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see pt.up.fe.specs.guihelper.AppSource#newInstance()
- */
- @Override
- public App newInstance() {
- return new EclipseDeploymentLauncher();
- }
-
- @Override
- public SetupDefinition getEnumKeys() {
- return SetupDefinition.create(EclipseDeploymentSetup.class);
- }
-
- @Override
- public String defaultConfigFile() {
- return DEFAULT_CONFIG;
- }
-
- private final static String DEFAULT_CONFIG = "default.config";
- private final static List baseResourceFiles = Arrays.asList(
- DeployResource.JAR_IN_JAR_LOADER.getResource());
-
-}
\ No newline at end of file
diff --git a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentSetup.java b/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentSetup.java
deleted file mode 100644
index 5ae49bc4..00000000
--- a/EclipseUtils/src/pt/up/fe/specs/eclipse/EclipseDeploymentSetup.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License. under the License.
- */
-
-package pt.up.fe.specs.eclipse;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.lang3.tuple.Pair;
-
-import pt.up.fe.specs.eclipse.Tasks.TaskUtils;
-import pt.up.fe.specs.guihelper.FieldType;
-import pt.up.fe.specs.guihelper.SetupAccess;
-import pt.up.fe.specs.guihelper.Base.ListOfSetupDefinitions;
-import pt.up.fe.specs.guihelper.Base.SetupFieldEnum;
-import pt.up.fe.specs.guihelper.BaseTypes.FieldValue;
-import pt.up.fe.specs.guihelper.BaseTypes.ListOfSetups;
-import pt.up.fe.specs.guihelper.BaseTypes.SetupData;
-import pt.up.fe.specs.guihelper.SetupFieldOptions.DefaultValue;
-import pt.up.fe.specs.guihelper.SetupFieldOptions.MultipleChoice;
-import pt.up.fe.specs.guihelper.SetupFieldOptions.MultipleSetup;
-import pt.up.fe.specs.util.properties.SpecsProperties;
-import pt.up.fe.specs.util.utilities.StringList;
-
-/**
- * Setup definition for program EclipseDeployment.
- *
- * @author Joao Bispo
- */
-public enum EclipseDeploymentSetup implements SetupFieldEnum, MultipleSetup, MultipleChoice, DefaultValue {
-
- WorkspaceFolder(FieldType.string),
- ProjectName(FieldType.string),
- NameOfOutputJar(FieldType.string),
- ClassWithMain(FieldType.string),
- OutputJarType(FieldType.multipleChoice),
- PomInfoFile(FieldType.string),
- DevelopersXml(FieldType.string),
- ProcessJar(FieldType.bool),
- Tasks(FieldType.setupList);
-
- public static EclipseDeploymentData newData(SetupData setupData) {
- SetupAccess setup = new SetupAccess(setupData);
-
- File workspaceFolder = setup.getFolderV2(null, WorkspaceFolder, true);
-
- String projetName = setup.getString(ProjectName);
- String nameOfOutputJar = setup.getString(NameOfOutputJar);
- Pair nameAndVersion = processOuputJarName(nameOfOutputJar);
- nameOfOutputJar = nameAndVersion.getLeft();
- String version = nameAndVersion.getRight();
- String mainClass = setup.getString(ClassWithMain);
-
- JarType jarType = setup.getEnum(OutputJarType, JarType.class);
-
- File pomInfoFile = setup.getString(PomInfoFile).strip().isEmpty() ? null
- : setup.getExistingFile(PomInfoFile);
- SpecsProperties pomInfo = pomInfoFile == null ? null : SpecsProperties.newInstance(pomInfoFile);
-
- File developersXml = setup.getString(DevelopersXml).strip().isEmpty() ? null
- : setup.getExistingFile(DevelopersXml);
-
- var processJar = setup.getBoolean(ProcessJar);
-
- ListOfSetups tasks = setup.getListOfSetups(Tasks);
-
- return new EclipseDeploymentData(workspaceFolder, projetName, nameOfOutputJar, mainClass, jarType, pomInfo,
- developersXml, version, processJar, tasks);
- }
-
- private static Pair processOuputJarName(String nameOfOutputJar) {
- String version = null;
-
- if (nameOfOutputJar.contains("%BUILD%")) {
- // Generate build number
- SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm");
- Date date = new Date(System.currentTimeMillis());
- version = formatter.format(date);
- nameOfOutputJar = nameOfOutputJar.replace("%BUILD%", version);
- }
- return Pair.of(nameOfOutputJar, version);
- // return nameOfOutputJar;
- }
-
- private EclipseDeploymentSetup(FieldType fieldType) {
- this.fieldType = fieldType;
- }
-
- @Override
- public FieldType getType() {
- return fieldType;
- }
-
- @Override
- public String getSetupName() {
- return "EclipseDeployment";
- }
-
- /**
- * INSTANCE VARIABLES
- */
- private final FieldType fieldType;
-
- /*
- * (non-Javadoc)
- *
- * @see pt.up.fe.specs.guihelper.SetupFieldOptions.MultipleSetup#getSetups()
- */
- @Override
- public ListOfSetupDefinitions getSetups() {
- /*
- * List> setups =
- * FactoryUtils.newArrayList();
- *
- * setups.addAll(TaskUtils.getTasks().keySet()); //
- * setups.add(FtpSetup.class); // setups.add(SftpSetup.class);
- *
- * return ListOfSetupDefinitions.newInstance(setups);
- */
- return getTasksDefinitions();
- }
-
- public static ListOfSetupDefinitions getTasksDefinitions() {
- List