-
Couldn't load subscription status.
- Fork 45
#36: Tool Commandlet for tomcat #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hohwille
merged 77 commits into
devonfw:main
from
aBega2000:feature/36-tool-commandlet-for-tomcat
Jul 3, 2024
Merged
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
a9f80db
#131: Support for tool dependencies
aBega2000 41d23ef
Merge branch 'main' of https://github.com/aBega2000/IDEasy into featu…
aBega2000 96f807f
Changes after review
aBega2000 ecd1df3
Update ToolCommandlet.java
aBega2000 b222aa5
#131: Changes after reviews
aBega2000 6080c80
Merge branch 'feature/131-support-for-tool-dependecies' of https://gi…
aBega2000 f7ff2c2
#131: Changes after review
aBega2000 e44d547
#131: Changes after review
aBega2000 4a6c8e9
Merge branch 'devonfw:main' into feature/131-support-for-tool-depende…
aBega2000 2805f0c
Merge branch 'feature/131-support-for-tool-dependecies' of https://gi…
aBega2000 67c5c9c
Small Change
aBega2000 cc8c0cb
#131: Changes after review
aBega2000 ed0b0f3
Merge branch 'feature/131-support-for-tool-dependecies' of https://gi…
aBega2000 18884c2
Merge branch 'main' into feature/131-support-for-tool-dependecies
jan-vcapgemini f2ed771
Merge branch 'devonfw:main' into feature/131-support-for-tool-depende…
aBega2000 32e4bd1
#131: Changes after review and according to VersionRange with boundar…
aBega2000 48e3437
Merge branch 'main' into feature/131-support-for-tool-dependecies
aBega2000 a3d82b9
Merge branch 'main' into feature/131-support-for-tool-dependecies
hohwille 21781f2
#131: Resolved Conflicts
aBega2000 e4ad57b
Merge commit '43272714a125e23e8b47d4501a16b722cde17ab2' into feature/…
aBega2000 b9846f8
Merge branch 'feature/131-support-for-tool-dependecies' of https://gi…
aBega2000 52840dc
Merge branch 'main' of https://github.com/aBega2000/IDEasy into featu…
aBega2000 fbcbf31
#131: Changes after review
aBega2000 0a9b2b5
Merge branch 'main' into feature/131-support-for-tool-dependecies
aBega2000 8f04879
Merge branch 'devonfw:main' into feature/131-support-for-tool-depende…
aBega2000 c9cbe8d
#36: Tool Commandlet for Tomcat
aBega2000 21ea541
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 2dc8b65
#36: Adding the software java folder
aBega2000 584c5f4
Update DependencyJson.java
hohwille f554f4d
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 19badd0
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 eb150c6
#36: changes after review
aBega2000 51479cf
Change in imports
aBega2000 4c0865b
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 c35281b
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 d5430eb
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 de64024
#36: Added Mac testing
aBega2000 a9c30dd
#36: Changes after Review
aBega2000 a0be0a6
#36: Added port printing for information
aBega2000 c14bdd0
Solved confilcts
aBega2000 2145ed6
Merge branch 'main' into feature/36-tool-commandlet-for-tomcat
aBega2000 75fa5fb
#36: Added more tests
aBega2000 28c2b83
#36: changes after error
aBega2000 c57392c
#36: added missing folder
aBega2000 cd43176
Update dependencies.json
aBega2000 1d6aca2
#36: Changed tests for running tomcat
aBega2000 f604d23
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 d4e35fc
#36: Changes after review
aBega2000 dce9f15
changed line ending
aBega2000 7a808ec
Merge branch 'main' into feature/36-tool-commandlet-for-tomcat
aBega2000 2c7abd4
#36: Changes after review
aBega2000 711e930
Update TomcatTest.java
aBega2000 d2833ab
#36: Changed the dependency env variables logic
aBega2000 ac94cd5
Merge branch 'feature/36-tool-commandlet-for-tomcat' of https://githu…
aBega2000 fa81af9
#36: Small change in LocalToolCommandlet
aBega2000 b456ece
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 1959b73
#36: Small changes in LocalToolCommandlet
aBega2000 065f60c
Merge branch 'feature/36-tool-commandlet-for-tomcat' of https://githu…
aBega2000 8a9e631
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 050101e
#36: Added functionalities
aBega2000 02ac6f3
#36: Name change
aBega2000 f384758
#36: Change for tests
aBega2000 1f0ba63
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 7bb7c9b
#36: Error case fixed
aBega2000 2ba9328
#36: Added functionaliy and JavaDocs
aBega2000 9344a04
#36: Changed JavaDoc
aBega2000 e2e562d
Merge branch 'main' into feature/36-tool-commandlet-for-tomcat
aBega2000 de3ab62
#36: Changes to Help.properites
aBega2000 dcb1d4c
#36: Fixed test error
aBega2000 0a26abe
#36: Added installation before running
aBega2000 758a3a2
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 1ec1585
Merge branch 'main' into feature/36-tool-commandlet-for-tomcat
aBega2000 c501587
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 499136d
Merge branch 'main' into feature/36-tool-commandlet-for-tomcat
aBega2000 6a294cd
Updated Help.properties
aBega2000 42f7a0c
Merge branch 'devonfw:main' into feature/36-tool-commandlet-for-tomcat
aBega2000 5e97f88
Merge branch 'main' into feature/36-tool-commandlet-for-tomcat
hohwille File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
cli/src/main/java/com/devonfw/tools/ide/tool/Dependency.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| package com.devonfw.tools.ide.tool; | ||
|
|
||
| import com.devonfw.tools.ide.context.IdeContext; | ||
| import com.devonfw.tools.ide.json.mapping.JsonMapping; | ||
| import com.devonfw.tools.ide.url.model.file.dependencyJson.DependencyInfo; | ||
| import com.devonfw.tools.ide.version.VersionIdentifier; | ||
| import com.devonfw.tools.ide.version.VersionRange; | ||
| import com.fasterxml.jackson.core.type.TypeReference; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
|
||
| import java.io.BufferedReader; | ||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.stream.Stream; | ||
|
|
||
| /** | ||
| * Class to represent the functionality of installing the dependencies when a tool is being installed. | ||
| */ | ||
| public class Dependency { | ||
|
|
||
| private final IdeContext context; | ||
|
|
||
| private final String tool; | ||
|
|
||
| private static final String DEPENDENCY_FILENAME = "dependencies.json"; | ||
|
|
||
| private static final ObjectMapper MAPPER = JsonMapping.create(); | ||
|
|
||
| /** | ||
| * The constructor. | ||
| * | ||
| * @param context the {@link IdeContext}. | ||
| * @param tool the tool of the context | ||
| */ | ||
| public Dependency(IdeContext context, String tool) { | ||
|
|
||
| this.context = context; | ||
| this.tool = tool; | ||
| } | ||
|
|
||
| /** | ||
| * Method to get the dependency json file path | ||
| * | ||
| * @param toolEdition the edition of the tool. | ||
| * @return the {@link Path} of the dependency.json file | ||
| */ | ||
| public Path getDependencyJsonPath(String toolEdition) { | ||
|
|
||
| Path toolPath = this.context.getUrlsPath().resolve(tool).resolve(toolEdition); | ||
| return toolPath.resolve(DEPENDENCY_FILENAME); | ||
| } | ||
|
|
||
| /** | ||
| * Method to read the Json file | ||
| * | ||
| * @param version of the main tool to be installed. | ||
| * @param toolEdition of the main tool, so that the correct folder can be checked to find the dependency json file | ||
| * @return the {@link List} of {@link DependencyInfo} to be installed | ||
| */ | ||
| public List<DependencyInfo> readJson(VersionIdentifier version, String toolEdition) { | ||
|
|
||
| Path dependencyJsonPath = getDependencyJsonPath(toolEdition); | ||
|
|
||
| try (BufferedReader reader = Files.newBufferedReader(dependencyJsonPath)) { | ||
| TypeReference<HashMap<VersionRange, List<DependencyInfo>>> typeRef = new TypeReference<>() { | ||
| }; | ||
| Map<VersionRange, List<DependencyInfo>> dependencyJson = MAPPER.readValue(reader, typeRef); | ||
| return findDependenciesFromJson(dependencyJson, version); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Method to search the List of versions available in the ide and find the right version to install | ||
| * | ||
| * @param dependencyFound the {@link DependencyInfo} of the dependency that was found that needs to be installed | ||
| * @return {@link VersionIdentifier} of the dependency that is to be installed | ||
| */ | ||
| public VersionIdentifier findDependencyVersionToInstall(DependencyInfo dependencyFound) { | ||
|
|
||
| String dependencyEdition = this.context.getVariables().getToolEdition(dependencyFound.getTool()); | ||
|
|
||
| List<VersionIdentifier> versions = this.context.getUrls().getSortedVersions(dependencyFound.getTool(), dependencyEdition); | ||
|
|
||
| for (VersionIdentifier vi : versions) { | ||
| if (dependencyFound.getVersionRange().contains(vi)) { | ||
| return vi; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Method to check if in the repository of the dependency there is a Version greater or equal to the version range to be installed, and to return the path of | ||
| * this version if it exists | ||
| * | ||
| * @param dependencyRepositoryPath the {@link Path} of the dependency repository | ||
| * @param dependencyVersionRangeFound the {@link VersionRange} of the dependency version to be installed | ||
| * @return the {@link Path} of such version if it exists in repository already, an empty Path | ||
| */ | ||
| public Path versionExistsInRepository(Path dependencyRepositoryPath, VersionRange dependencyVersionRangeFound) { | ||
|
|
||
| try (Stream<Path> versions = Files.list(dependencyRepositoryPath)) { | ||
| Iterator<Path> versionsIterator = versions.iterator(); | ||
| while (versionsIterator.hasNext()) { | ||
| VersionIdentifier versionFound = VersionIdentifier.of(versionsIterator.next().getFileName().toString()); | ||
| if (dependencyVersionRangeFound.contains(versionFound)) { | ||
| assert versionFound != null; | ||
| return dependencyRepositoryPath.resolve(versionFound.toString()); | ||
| } | ||
| } | ||
| } catch (IOException e) { | ||
| throw new IllegalStateException("Failed to iterate through " + dependencyRepositoryPath, e); | ||
| } | ||
| return Path.of(""); | ||
| } | ||
|
|
||
| private List<DependencyInfo> findDependenciesFromJson(Map<VersionRange, List<DependencyInfo>> dependencies, VersionIdentifier toolVersionToCheck) { | ||
|
|
||
| for (Map.Entry<VersionRange, List<DependencyInfo>> map : dependencies.entrySet()) { | ||
|
|
||
| VersionRange foundToolVersionRange = map.getKey(); | ||
|
|
||
| if (foundToolVersionRange.contains(toolVersionToCheck)) { | ||
| return map.getValue(); | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.