Skip to content

Commit

Permalink
Merge branch 'main' into feature/320-help-details
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Jun 17, 2024
2 parents a5edb70 + b870e36 commit e263f16
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 41 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: graalvm/setup-graalvm@v1
with:
java-version: '21.0.2'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: Build native images with nativ maven plugin and extract in tar.gz
shell: bash
run: |
mvn -B -ntp -Pnative -DskipTests=true package
mvn -B -ntp -Pnative -DskipTests=true package -pl cli
- uses: actions/upload-artifact@v3
with:
name: natives
Expand Down Expand Up @@ -72,17 +69,3 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dgpg.skip=true -Dstyle.color=always -B -ntp -P deploy deploy

cancel:
name: Cancel this workflow
runs-on: ubuntu-latest
needs: verify_commit
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
RUN_ID: ${{ github.run_id }}
steps:
- run: |
curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/actions/runs/$RUN_ID/cancel"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.devonfw.tools.ide.context.GitContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.property.FlagProperty;
import com.devonfw.tools.ide.property.StringProperty;
import com.devonfw.tools.ide.repo.CustomTool;
import com.devonfw.tools.ide.step.Step;
Expand All @@ -23,6 +24,9 @@ public abstract class AbstractUpdateCommandlet extends Commandlet {
/** {@link StringProperty} for the settings repository URL. */
protected final StringProperty settingsRepo;

/** {@link FlagProperty} for skipping installation/updating of tools */
protected final FlagProperty skipTools;

/**
* The constructor.
*
Expand All @@ -31,15 +35,27 @@ public abstract class AbstractUpdateCommandlet extends Commandlet {
public AbstractUpdateCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
this.skipTools = add(new FlagProperty("--skip-tools", false, null));
this.settingsRepo = new StringProperty("", false, "settingsRepository");
}

@Override
public void run() {

updateSettings();
Path templatesFolder = this.context.getSettingsPath().resolve(IdeContext.FOLDER_TEMPLATES);
updateConf();

if (skipTools.isTrue()) {
this.context.info("Skipping installation/update of tools as specified by the user.");
} else {
updateSoftware();
}
}

private void updateConf() {

Path templatesFolder = this.context.getSettingsPath().resolve(IdeContext.FOLDER_TEMPLATES);
if (!Files.exists(templatesFolder)) {
Path legacyTemplatesFolder = this.context.getSettingsPath().resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
if (Files.exists(legacyTemplatesFolder)) {
Expand All @@ -57,7 +73,6 @@ public void run() {
} finally {
step.end();
}
updateSoftware();
}

private void setupConf(Path template, Path conf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ public List<Property<?>> getValues() {
}

/**
* @param nameOrAlias the potential {@link Property#getName() name} or {@link Property#getAlias() alias} of the requested {@link Property}.
* Clear the set values on all properties of the {@link Commandlet#propertiesList}
*/
public void clearProperties() {

for (Property<?> property : this.propertiesList) {
property.clearValue();
}
}

/**
* @param nameOrAlias the potential {@link Property#getName() name} or {@link Property#getAlias() alias} of the
* requested {@link Property}.
* @return the requested {@link Property property} or {@code null} if not found.
*/
public Property<?> getOption(String nameOrAlias) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.property.FlagProperty;
import com.devonfw.tools.ide.property.StringProperty;

import java.nio.file.Path;
Expand All @@ -11,8 +12,12 @@
*/
public class CreateCommandlet extends AbstractUpdateCommandlet {

/** {@link StringProperty} for the name of the new project */
public final StringProperty newProject;

/** {@link FlagProperty} for skipping the setup of git repositories */
public final FlagProperty skipRepositories;

/**
* The constructor.
*
Expand All @@ -21,8 +26,8 @@ public class CreateCommandlet extends AbstractUpdateCommandlet {
public CreateCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
newProject = add(new StringProperty("", true, "project"));
this.skipRepositories = add(new FlagProperty("--skip-repositories", false, null));
add(this.settingsRepo);
}

Expand Down Expand Up @@ -54,7 +59,11 @@ public void run() {
initializeProject(newProjectPath);
this.context.setIdeHome(newProjectPath);
super.run();
updateRepositories();
if (this.skipRepositories.isTrue()) {
this.context.info("Skipping the cloning of project repositories as specified by the user.");
} else {
updateRepositories();
}
this.context.success("Successfully created new project '{}'.", newProjectName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class UpdateCommandlet extends AbstractUpdateCommandlet {
public UpdateCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,13 +871,15 @@ public int run(CliArguments arguments) {
}

/**
* @param cmd the potential {@link Commandlet} to {@link #apply(CliArguments, Commandlet, CompletionCandidateCollector) apply} and
* {@link Commandlet#run() run}.
* @return {@code true} if the given {@link Commandlet} matched and did {@link Commandlet#run() run} successfully, {@code false} otherwise (the
* {@link Commandlet} did not match and we have to try a different candidate).
* @param cmd the potential {@link Commandlet} to
* {@link #apply(CliArguments, Commandlet, CompletionCandidateCollector) apply} and {@link Commandlet#run() run}.
* @return {@code true} if the given {@link Commandlet} matched and did {@link Commandlet#run() run} successfully,
* {@code false} otherwise (the {@link Commandlet} did not match and we have to try a different candidate).
*/
private boolean applyAndRun(CliArguments arguments, Commandlet cmd) {

cmd.clearProperties();

boolean matches = apply(arguments, cmd, null);
if (matches) {
matches = cmd.validate();
Expand Down
13 changes: 12 additions & 1 deletion cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
*/
public class FileAccessImpl implements FileAccess {

private static final String WINDOWS_FILE_LOCK_DOCUMENTATION_PAGE = "https://github.com/devonfw/IDEasy/blob/main/documentation/windows-file-lock.adoc";

private static final String WINDOWS_FILE_LOCK_WARNING =
"On Windows, file operations could fail due to file locks. Please ensure the files in the moved directory are not in use. For further details, see: \n"
+ WINDOWS_FILE_LOCK_DOCUMENTATION_PAGE;

private final IdeContext context;

/**
Expand Down Expand Up @@ -275,7 +281,12 @@ public void move(Path source, Path targetDir) {
try {
Files.move(source, targetDir);
} catch (IOException e) {
throw new IllegalStateException("Failed to move " + source + " to " + targetDir, e);
String fileType = Files.isSymbolicLink(source) ? "symlink" : isJunction(source) ? "junction" : Files.isDirectory(source) ? "directory" : "file";
String message = "Failed to move " + fileType + ": " + source + " to " + targetDir + ".";
if (this.context.getSystemInfo().isWindows()) {
message = message + "\n" + WINDOWS_FILE_LOCK_WARNING;
}
throw new IllegalStateException(message, e);
}
}

Expand Down
15 changes: 11 additions & 4 deletions cli/src/main/java/com/devonfw/tools/ide/property/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,17 @@ protected String format(V valueToFormat) {
*/
public void setValue(V value) {

if (!this.multivalued) {
this.value.clear();
}
this.value.add(value);
}

/**
* Clears the {@link #value value} list.
*/
public void clearValue() {

this.value.clear();
}

public void addValue(V value) {

if (!this.multivalued) {
Expand Down Expand Up @@ -454,7 +459,9 @@ public boolean validate() {
return false;
}
if (this.validator != null) {
this.validator.accept(getValue());
for (V value : this.value) {
this.validator.accept(value);
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.devonfw.tools.ide.tool.jasypt;

import com.devonfw.tools.ide.url.updater.MavenBasedUrlUpdater;
import com.devonfw.tools.ide.version.VersionIdentifier;

/**
* {@link MavenBasedUrlUpdater} for jasypt
*/
public class JasyptUrlUpdater extends MavenBasedUrlUpdater {

public static final VersionIdentifier MIN_VERSION = VersionIdentifier.of("1.9.3");

@Override
protected String getTool() {

Expand All @@ -24,4 +28,14 @@ protected String getMavenArtifcatId() {
return "jasypt";
}

@Override
public boolean isValidVersion(String version) {

VersionIdentifier artifactVersion = VersionIdentifier.of(version);
if (artifactVersion != null) {
return artifactVersion.isGreaterOrEqual(MIN_VERSION);
}
return false;
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.devonfw.tools.ide.url.updater;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import com.devonfw.tools.ide.maven.MavenMetadata;
import com.devonfw.tools.ide.url.model.folder.UrlVersion;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
* The MvnCrawler class is an abstract class that provides functionality for crawling Maven repositories.
*/
Expand All @@ -23,8 +23,7 @@ public abstract class MavenBasedUrlUpdater extends AbstractUrlUpdater {
public MavenBasedUrlUpdater() {

super();
this.mavenBaseRepoUrl = "https://repo1.maven.org/maven2/" + getMavenGroupIdPath() + "/" + getMavenArtifcatId()
+ "/";
this.mavenBaseRepoUrl = "https://repo1.maven.org/maven2/" + getMavenGroupIdPath() + "/" + getMavenArtifcatId() + "/";

}

Expand Down Expand Up @@ -74,12 +73,25 @@ private Set<String> doGetVersionsFromMavenApi(String url) {
XmlMapper mapper = new XmlMapper();
MavenMetadata metaData = mapper.readValue(response, MavenMetadata.class);
for (String version : metaData.getVersioning().getVersions()) {
addVersion(version, versions);
if (isValidVersion(version)) {
addVersion(version, versions);
}
}
} catch (IOException e) {
throw new IllegalStateException("Failed to get version from " + url, e);
}
return versions;
}

/**
* Subclasses should override this method to enforce version validation.
*
* @param version the version of the artifact.
* @return true as default implementation.
*/
protected boolean isValidVersion(String version) {

return true;
}

}
2 changes: 2 additions & 0 deletions cli/src/main/resources/nls/Help.properties
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ opt.--force=enable force mode.
opt.--locale=the locale (e.g. '--locale=de' for German language).
opt.--offline=enable offline mode (skip updates or git pull, fail downloads or git clone).
opt.--quiet=disable info logging (only log success, warning or error).
opt.--skip-repositories=skip the setup of repositories.
opt.--skip-tools=skip the installation/update of tools.
opt.--trace=enable trace logging.
opt.--version=Print the IDE version and exit.
options=Options:
Expand Down
2 changes: 2 additions & 0 deletions cli/src/main/resources/nls/Help_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ opt.--force=Aktiviert den Force-Modus (Erzwingen).
opt.--locale=Die Spracheinstellungen (z.B. 'en' für Englisch).
opt.--offline=Aktiviert den Offline-Modus (Überspringt Aktualisierungen oder git pull, schlägt fehl bei Downloads or git clone).
opt.--quiet=Deaktiviert Info Logging ( nur success, warning und error).
opt.--skip-repositories=überspringt die Einrichtung der Repositories.
opt.--skip-tools=überspringt die Installation/Aktualisierung der Tools.
opt.--trace=Aktiviert Trace-Ausgaben (detaillierte Fehleranalyse).
opt.--version=Zeigt die IDE Version an und beendet das Programm.
options=Optionen:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void testCreateCommandletRun() {
CreateCommandlet cc = context.getCommandletManager().getCommandlet(CreateCommandlet.class);
cc.newProject.setValueAsString(NEW_PROJECT_NAME, context);
cc.settingsRepo.setValue(IdeContext.DEFAULT_SETTINGS_REPO_URL);
cc.skipTools.setValue(true);
// act
cc.run();
// assert
Expand Down
3 changes: 2 additions & 1 deletion documentation/software.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Technically we "install" (extract) all tools into a local repository (in `$IDE_R
This has the following benefits:

* Switching a tool version forth and back is lightning fast since only a symbolic link needs to be updated.
* We avoid severe issues with link:how-to-unlock-files.adoc[Windows file-locking].
* We avoid severe issues with link:windows-file-lock.adoc[Windows file-locking].
* Multiple IDEasy projects can share the same physical tool versions to save disc-space.
However, we keep previous tool version on updates what can also waste disc-space.
Therefore, you can run `ide cleanup` to find and release old tool versions and free disc-space.
Expand All @@ -23,6 +23,7 @@ Therefore, you can run `ide cleanup` to find and release old tool versions and f
In some cases, a project might need a (proprietary) tools that are not directly supported by `IDEasy`.
As a solution for this need, `IDEasy` let's you configure custom tools via `settings/ide-custom-tools.json`.
The following example illustrates how to configure custom tools:

```json
{
"url": "https://some-file-server.company.com/projects/my-project",
Expand Down
File renamed without changes.

0 comments on commit e263f16

Please sign in to comment.