-
Notifications
You must be signed in to change notification settings - Fork 18
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
#25: implement tool commandlet for intellij #297
base: main
Are you sure you want to change the base?
Changes from all commits
13a2b75
b8292b6
bcf0e4b
1194c04
2213057
4329115
b1f7e9c
a1ae18a
3402cc7
2d39454
0bd0b42
1599acb
2dbd602
c4ae3cf
e26ce93
7b63574
93265c9
dd5b979
ab2bedd
5f5b2a9
a87dde9
ca10f69
6e46659
053faed
35012f0
b9af487
13c526f
c9af2b5
7733bfc
4bbb95b
2c8820a
9ed18b4
789f5c7
5463998
a3cb929
1c25fb4
02ce32c
1589f88
9f5d2f7
1664414
548357d
35c7d63
480a472
408b8e7
30e4048
20e8710
a45b108
bf7fa79
26e902f
3382e54
40eb875
30062f3
ad6f549
63793c8
9ca87e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,18 +1,33 @@ | ||||||
package com.devonfw.tools.ide.tool.intellij; | ||||||
|
||||||
import com.devonfw.tools.ide.cli.CliArgument; | ||||||
import com.devonfw.tools.ide.common.Tag; | ||||||
import com.devonfw.tools.ide.context.IdeContext; | ||||||
import com.devonfw.tools.ide.io.FileAccessImpl; | ||||||
import com.devonfw.tools.ide.process.ProcessMode; | ||||||
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet; | ||||||
import com.devonfw.tools.ide.tool.ide.PluginDescriptor; | ||||||
import com.devonfw.tools.ide.tool.java.Java; | ||||||
import com.devonfw.tools.ide.version.VersionIdentifier; | ||||||
|
||||||
import java.io.IOException; | ||||||
import java.nio.file.Files; | ||||||
import java.nio.file.Path; | ||||||
import java.nio.file.attribute.PosixFilePermission; | ||||||
import java.nio.file.attribute.PosixFilePermissions; | ||||||
import java.util.Set; | ||||||
|
||||||
/** | ||||||
* {@link IdeToolCommandlet} for <a href="https://www.jetbrains.com/idea/">IntelliJ</a>. | ||||||
*/ | ||||||
public class Intellij extends IdeToolCommandlet { | ||||||
|
||||||
private static final String IDEA = "idea"; | ||||||
|
||||||
private static final String IDEA64_EXE = IDEA + "64.exe"; | ||||||
|
||||||
private static final String IDEA_BASH_SCRIPT = IDEA + ".sh"; | ||||||
|
||||||
/** | ||||||
* The constructor. | ||||||
* | ||||||
|
@@ -23,6 +38,27 @@ public Intellij(IdeContext context) { | |||||
super(context, "intellij", Set.of(Tag.INTELLIJ)); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public void runTool(ProcessMode processMode, VersionIdentifier toolVersion, String... args) { | ||||||
|
||||||
install(true); | ||||||
args = CliArgument.prepend(args, this.context.getWorkspacePath().toString()); | ||||||
super.runTool(processMode, toolVersion, args); | ||||||
} | ||||||
|
||||||
@Override | ||||||
protected String getBinaryName() { | ||||||
|
||||||
Path toolBinPath = getToolBinPath(); | ||||||
if (this.context.getSystemInfo().isWindows()) { | ||||||
return toolBinPath.resolve(IDEA64_EXE).toString(); | ||||||
} else if (this.context.getSystemInfo().isLinux()) { | ||||||
return toolBinPath.resolve(IDEA_BASH_SCRIPT).toString(); | ||||||
} else { | ||||||
return getToolPath().resolve("IntelliJ IDEA CE.app").resolve("Contents").resolve("MacOS").resolve(IDEA).toString(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO this is still wrong as we discussed in our meeting. |
||||||
} | ||||||
} | ||||||
|
||||||
@Override | ||||||
public boolean install(boolean silent) { | ||||||
|
||||||
|
@@ -31,10 +67,31 @@ public boolean install(boolean silent) { | |||||
} | ||||||
|
||||||
@Override | ||||||
public void installPlugin(PluginDescriptor plugin) { | ||||||
protected void postInstall() { | ||||||
|
||||||
super.postInstall(); | ||||||
if (this.context.getSystemInfo().isMac()) { | ||||||
setMacOsFilePermissions(getToolPath().resolve("IntelliJ IDEA CE.app").resolve("Contents").resolve("MacOS").resolve(IDEA)); | ||||||
} | ||||||
Comment on lines
+73
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here... |
||||||
} | ||||||
|
||||||
// TODO Auto-generated method stub | ||||||
private static void setMacOsFilePermissions(Path binaryFile) { | ||||||
|
||||||
if (Files.exists(binaryFile)) { | ||||||
String permissionStr = FileAccessImpl.generatePermissionString(493); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems I missed to discuss on this API.
|
||||||
Set<PosixFilePermission> permissions = PosixFilePermissions.fromString(permissionStr); | ||||||
try { | ||||||
Files.setPosixFilePermissions(binaryFile, permissions); | ||||||
} catch (IOException e) { | ||||||
throw new RuntimeException(e); | ||||||
} finally { | ||||||
return; | ||||||
Comment on lines
+87
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem to add any value and is IMHO only causing confusion.
Suggested change
|
||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
} | ||||||
@Override | ||||||
public void installPlugin(PluginDescriptor plugin) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not implemented so this PR does not entirely close #25. If you do something like this on purpose, then create a new issue for IntelliJ plugin support and leave a comment here like |
||||||
|
||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.devonfw.tools.ide.tool.intellij; | ||
|
||
import com.devonfw.tools.ide.context.AbstractIdeContextTest; | ||
import com.devonfw.tools.ide.context.IdeTestContext; | ||
import com.devonfw.tools.ide.log.IdeLogLevel; | ||
import com.devonfw.tools.ide.os.SystemInfo; | ||
import com.devonfw.tools.ide.os.SystemInfoMock; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import java.nio.file.Path; | ||
|
||
/** | ||
* Integration test of {@link Intellij}. | ||
*/ | ||
public class IntellijTest extends AbstractIdeContextTest { | ||
|
||
private static final String PROJECT_INTELLIJ = "intellij"; | ||
|
||
private final IdeTestContext context = newContext(PROJECT_INTELLIJ); | ||
|
||
/** | ||
* Tests if the {@link Intellij} can be installed properly. | ||
* | ||
* @param os String of the OS to use. | ||
*/ | ||
@ParameterizedTest | ||
@ValueSource(strings = { "windows", "mac", "linux" }) | ||
public void testIntellijInstall(String os) { | ||
|
||
// arrange | ||
SystemInfo systemInfo = SystemInfoMock.of(os); | ||
context.setSystemInfo(systemInfo); | ||
Intellij commandlet = new Intellij(context); | ||
|
||
// act | ||
commandlet.install(); | ||
|
||
// assert | ||
checkInstallation(context); | ||
|
||
//if tool already installed | ||
commandlet.install(); | ||
assertLogMessage(context, IdeLogLevel.DEBUG, "Version 2023.3.3 of tool intellij is already installed"); | ||
} | ||
|
||
/** | ||
* Tests if {@link Intellij IntelliJ IDE} can be run. | ||
* | ||
* @param os String of the OS to use. | ||
*/ | ||
@ParameterizedTest | ||
@ValueSource(strings = { "windows", "mac", "linux" }) | ||
public void testIntellijRun(String os) { | ||
// arrange | ||
SystemInfo systemInfo = SystemInfoMock.of(os); | ||
context.setSystemInfo(systemInfo); | ||
Intellij commandlet = new Intellij(context); | ||
|
||
// act | ||
commandlet.run(); | ||
|
||
// assert | ||
SystemInfo currentSystemInfo = context.getSystemInfo(); | ||
Path workspacePath = this.context.getWorkspacePath(); | ||
|
||
if (currentSystemInfo.isMac()) { | ||
assertLogMessage(context, IdeLogLevel.INFO, "intellij mac " + workspacePath); | ||
} else if (currentSystemInfo.isLinux()) { | ||
assertLogMessage(context, IdeLogLevel.INFO, "intellij linux " + workspacePath); | ||
} else if (currentSystemInfo.isWindows()) { | ||
assertLogMessage(context, IdeLogLevel.INFO, "intellij windows " + workspacePath); | ||
} | ||
checkInstallation(context); | ||
} | ||
|
||
private void checkInstallation(IdeTestContext context) { | ||
|
||
assertThat(context.getSoftwarePath().resolve("intellij/.ide.software.version")).exists().hasContent("2023.3.3"); | ||
assertLogMessage(context, IdeLogLevel.SUCCESS, "Successfully installed java in version 17.0.10_7"); | ||
assertLogMessage(context, IdeLogLevel.SUCCESS, "Successfully installed intellij in version 2023.3.3"); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this full path really required? Assuming we do some small refactoring and the path changes nobody will remember to also fix this path here?