Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/update-urls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jobs:
repository: devonfw/ide-urls
path: ide-urls
token: ${{ secrets.ACTION_PUSH_TOKEN }}
- name: Checkout ide-urls-status
uses: actions/checkout@v3
with:
repository: devonfw/ide-urls-status
path: ide-urls-status
token: ${{ secrets.ACTION_PUSH_TOKEN }}
- name: Set up Java
uses: actions/setup-java@v3
with:
Expand All @@ -26,7 +32,7 @@ jobs:
- name: Build and run url updater
run: |
mvn -B -ntp -Dstyle.color=always -pl url-updater -am install
mvn -B -ntp -Dstyle.color=always -pl url-updater exec:java -Dexec.mainClass="com.devonfw.tools.ide.url.UpdateInitiator" -Dexec.args="ide-urls PT5H30M"
mvn -B -ntp -Dstyle.color=always -pl url-updater exec:java -Dexec.mainClass="com.devonfw.tools.ide.url.UpdateInitiator" -Dexec.args="ide-urls ide-urls-status PT5H30M"
env:
GHA_TOKEN: ${{ secrets.GHA_TOKEN }}
- name: Commit and push to ide-urls
Expand All @@ -42,6 +48,19 @@ jobs:
else
echo "No changes, nothing to commit."
fi
- name: Commit and push status.json files to ide-urls-status
run: |
cd ide-urls-status
git config --global user.name ${{ secrets.BUILD_USER }}
git config --global user.email ${{ secrets.BUILD_USER_EMAIL }}
if git status -z | grep -q .
then
git add .
git commit -m "Update status.json"
git push
else
echo "No status.json changes"
fi
trigger_update_cve:
runs-on: ubuntu-latest
needs: updateURLS
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/1651[#1651]: Move status.json files out of ide-urls to ide-urls-status

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/47?closed=1[milestone 2026.07.002].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
public class UrlRepository extends AbstractUrlFolder<UrlTool> {

private UrlRepository statusRepository;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An UrlRepository should not contain another UrlRepository.
BTW: Maybe it was wrong from the start to have the UrlStatusFile in cli module since we never read it from IDEasy itself. It is only used by UrlUpdater and nowhere else.
I would suggest to revert all these changes.
Simply determine the path to the status file from the path to the version folder (from UrlVersion.getPath()).


/**
* The constructor.
*
Expand Down Expand Up @@ -39,4 +41,21 @@ protected UrlTool newChild(String name) {
return new UrlTool(this, name);
}

/**
* @return the {@link UrlRepository} used to store status files.
*/
public UrlRepository getStatusRepository() {
if (this.statusRepository == null) {
return this;
}
return this.statusRepository;
}


/**
* @param statusRepository the {@link UrlRepository} used to store status files.
*/
public void setStatusRepository(UrlRepository statusRepository) {
this.statusRepository = statusRepository;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,62 @@ public static String getUrlsFileName(OperatingSystem os, SystemArchitecture arch
return os + "_" + SystemArchitecture.orDefault(arch) + UrlDownloadFile.EXTENSION_URLS;
}

/**
* @return the matching {@link UrlVersion} in the status repository, or this version if no separate status repository is configured.
*/
private UrlVersion getStatusVersion() {
UrlRepository statusRepository = getParent().getParent().getParent().getStatusRepository();
String toolName = getParent().getParent().getName();
String editionName = getParent().getName();
String versionName = getName();
UrlTool statusTool = statusRepository.getChild(toolName);
if (statusTool == null) {
return null;
}
UrlEdition statusEdition = statusTool.getChild(editionName);
if (statusEdition == null) {
return null;
}
return statusEdition.getChild(versionName);
}


/**
* @return the matching {@link UrlVersion} in the status repository. It will be created if it does not exist.
*/
private UrlVersion getOrCreateStatusVersion() {

UrlRepository statusRepository = getParent().getParent().getParent().getStatusRepository();

String toolName = getParent().getParent().getName();
String editionName = getParent().getName();
String versionName = getName();

UrlTool statusTool = statusRepository.getOrCreateChild(toolName);
UrlEdition statusEdition = statusTool.getOrCreateChild(editionName);

return statusEdition.getOrCreateChild(versionName);
}

/**
* @return the {@link UrlStatusFile}.
*/
public UrlStatusFile getStatus() {

return (UrlStatusFile) getChild(UrlStatusFile.STATUS_JSON);
UrlVersion statusVersion = getStatusVersion();
if (statusVersion == null) {
return null;
}
return (UrlStatusFile) statusVersion.getChild(UrlStatusFile.STATUS_JSON);
}

/**
* @return the {@link UrlStatusFile}.
*/
public UrlStatusFile getOrCreateStatus() {

return (UrlStatusFile) getOrCreateChild(UrlStatusFile.STATUS_JSON);
UrlVersion statusVersion = getOrCreateStatusVersion();
return (UrlStatusFile) statusVersion.getOrCreateChild(UrlStatusFile.STATUS_JSON);
}

/**
Expand Down Expand Up @@ -210,7 +252,11 @@ protected boolean isAllowedChild(String name, boolean folder) {
@Override
public void save() {

UrlVersion statusVersion = getStatusVersion();
if (getChildCount() == 0) {
if ((statusVersion != null) && (statusVersion != this)) {
statusVersion.save();
}
return;
}
Path path = getPath();
Expand All @@ -220,6 +266,9 @@ public void save() {
throw new IllegalStateException("Failed to create directory " + path, e);
}
super.save();
if ((statusVersion != null) && (statusVersion != this)) {
statusVersion.save();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,63 @@ public class UpdateInitiator {
private static final Logger logger = LoggerFactory.getLogger(UpdateInitiator.class.getName());

/**
* @param args the command-line arguments. arg[0] points to the {@code ide-urls} repository. arg[1] defines a timeout for GitHub actions in Duration
* string format and arg[2] (optional) can be used to specify a single tool to update instead of all tools, either by toolname (e.g. java) or using the Classname of
* the Updater (e.g. JavaAzulUrlUpdater). The timeout is used to prevent the GitHub action from running into a timeout error due to too long execution
* time.
* @param args the command-line arguments. arg[0] points to the {@code ide-urls} repository. arg[1] points to the {@code ide-urls-status} repository.
* arg[2] defines a timeout for GitHub actions in Duration string format and arg[3] (optional) can be used to specify a single tool to update instead of
* all tools, either by toolname (e.g. java) or using the Classname of the Updater (e.g. JavaAzulUrlUpdater). The timeout is used to prevent the GitHub
* action from running into a timeout error due to too long execution time.
*/
public static void main(String[] args) {

if (args.length == 0) {
logger.error("Error: Missing path to repository as well as missing timeout as command line arguments.");
logger.error("Usage: java UpdateInitiator <path_to_repository> <duration_string_format> <tool_to_test|updater_class_name>");
logger.error(
"Usage: java UpdateInitiator <path_to_url_repository> <path_to_status_repository> <duration_string_format> <tool_to_test|updater_class_name>");
System.exit(1);
}

String pathToRepo = args[0];
if (args.length < 2) {
logger.error("Error: Missing path to URL repository and/or status repository.");
logger.error(
"Usage: java UpdateInitiator <path_to_url_repository> <path_to_status_repository> <duration_string_format> <tool_to_test|updater_class_name>");
System.exit(1);
}
Comment on lines 29 to +41

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need two if now.
The first one (if (args.length == 0)) does not make sense any more and shall be removed.


String pathToUrlRepo = args[0];
String pathToStatusRepo = args[1];
Instant expirationTime = null;
String selectedTool = null;

if (args.length < 2) {
if (args.length < 3) {
logger.warn("Timeout was not set, setting timeout to infinite instead.");
} else {
try {
Duration duration = Duration.parse(args[1]);
Duration duration = Duration.parse(args[2]);
expirationTime = Instant.now().plus(duration);
logger.info("Timeout was set to: {}.", expirationTime);
} catch (DateTimeParseException e) {
logger.error("Error: Provided timeout format is not valid.", e);
System.exit(1);
}
if (args.length > 2) {
selectedTool = args[2];
if (args.length > 3) {
selectedTool = args[3];
}
}

Path repoPath = Path.of(pathToRepo);
Path urlRepoPath = Path.of(pathToUrlRepo);
Path statusRepoPath = Path.of(pathToStatusRepo);

if (!repoPath.toFile().isDirectory()) {
logger.error("Error: Provided path is not a valid directory.");
if (!urlRepoPath.toFile().isDirectory()) {
logger.error("Error: Provided URL repository path is not a valid directory.");
System.exit(1);
}
if (!statusRepoPath.toFile().isDirectory()) {
logger.error("Error: Provided status repository path is not a valid directory.");
System.exit(1);
}

UrlFinalReport urlFinalReport = new UrlFinalReport();

UpdateManager updateManager = new UpdateManager(repoPath, urlFinalReport, expirationTime);
UpdateManager updateManager = new UpdateManager(urlRepoPath, statusRepoPath, urlFinalReport, expirationTime);
if (selectedTool == null) {
updateManager.updateAll();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class UpdateManager extends AbstractProcessorWithTimeout {

private final UrlRepository urlRepository;

private final UrlRepository statusRepository;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this as Path and simply derive the path to the status.json by resolving the relative path inside the repo to the version (e.g. java/java/25.0.3_9) to it plus the constant for "status.json".
I would delete UrlStatusFile.
Also consider moving StatusJson, UrlStatus, and UrlStatusState from cli to url-updater module.
If we need caching of these files, we can simply use a map from path to the parsed StatusJson.
If you want to keep a wrapper object with Path reference and load + save methods also fine but no need to extend that from AbstractUrlFile anymore.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this PR is IMHO still writing to the old locations. Code like this needs to be adopted:

UrlStatusFile urlStatusFile = urlVersion.getStatus();
boolean forceCreation = (success || update);
if ((urlStatusFile == null) && forceCreation) {
urlStatusFile = urlVersion.getOrCreateStatus();
}
StatusJson statusJson = null;

When really deleting UrlStatusFile you will get compile errors revealing the problems to rework.


private final UrlFinalReport urlFinalReport;

private final List<AbstractUrlUpdater> updaters = List.of(
Expand All @@ -90,15 +92,29 @@ public class UpdateManager extends AbstractProcessorWithTimeout {
* The constructor.
*
* @param pathToRepository the {@link Path} to the {@code ide-urls} repository to update.
* @param pathToStatusRepository the {@link Path} to the {@code ide-urls-status} repository to update.
* @param expirationTime for GitHub actions url-update job
*/
public UpdateManager(Path pathToRepository, UrlFinalReport urlFinalReport, Instant expirationTime) {
public UpdateManager(Path pathToRepository, Path pathToStatusRepository, UrlFinalReport urlFinalReport, Instant expirationTime) {

this.urlRepository = UrlRepository.load(pathToRepository);
this.statusRepository = UrlRepository.load(pathToStatusRepository);
this.urlRepository.setStatusRepository(this.statusRepository);
this.urlFinalReport = urlFinalReport;
setExpirationTime(expirationTime);
}

/**
* The constructor.
*
* @param pathToRepository the {@link Path} to the {@code ide-urls} repository to update.
* @param expirationTime for GitHub actions url-update job.
*/
public UpdateManager(Path pathToRepository, UrlFinalReport urlFinalReport, Instant expirationTime) {

this(pathToRepository, pathToRepository, urlFinalReport, expirationTime);
}

/**
* @return the {@link List} with all registered {@link AbstractUrlUpdater updaters}.
*/
Expand Down
Loading