-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
295e130
commit 07e8cb2
Showing
11 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
|
||
# special handling for test files | ||
studio64.exe text | ||
idea64.exe text |
This file contains 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
92 changes: 92 additions & 0 deletions
92
cli/src/main/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudio.java
This file contains 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,92 @@ | ||
package com.devonfw.tools.ide.tool.androidstudio; | ||
|
||
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.FileAccess; | ||
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.version.VersionIdentifier; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Set; | ||
|
||
/** | ||
* {@link IdeToolCommandlet} for <a href="https://developer.android.com/studio">AndroidStudio</a>. | ||
*/ | ||
public class AndroidStudio extends IdeToolCommandlet { | ||
|
||
private static final String STUDIO = "studio"; | ||
|
||
private static final String STUDIO64_EXE = STUDIO + "64.exe"; | ||
|
||
private static final String STUDIO_BASH = STUDIO + ".sh"; | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param context the {@link IdeContext}. | ||
*/ | ||
public AndroidStudio(IdeContext context) { | ||
|
||
super(context, "android-studio", Set.of(Tag.ANDROID_STUDIO)); | ||
} | ||
|
||
@Override | ||
protected String getBinaryName() { | ||
|
||
Path toolBinPath = getToolBinPath(); | ||
if (this.context.getSystemInfo().isWindows()) { | ||
return STUDIO64_EXE; | ||
} else if (this.context.getSystemInfo().isLinux()) { | ||
return STUDIO_BASH; | ||
} else { | ||
return STUDIO; | ||
} | ||
} | ||
|
||
@Override | ||
public void runTool(ProcessMode processMode, VersionIdentifier toolVersion, String... args) { | ||
|
||
args = CliArgument.prepend(args, this.context.getWorkspacePath().toString()); | ||
|
||
install(true); | ||
super.runTool(processMode, toolVersion, args); | ||
|
||
} | ||
|
||
@Override | ||
public boolean install(boolean silent) { | ||
|
||
return super.install(silent); | ||
} | ||
|
||
@Override | ||
protected void postInstall() { | ||
|
||
super.postInstall(); | ||
if (this.context.getSystemInfo().isMac()) { | ||
setMacOsFilePermissions(getToolPath().resolve("Android Studio Preview.app").resolve("Contents").resolve("MacOS").resolve(STUDIO)); | ||
} | ||
} | ||
|
||
private void setMacOsFilePermissions(Path binaryFile) { | ||
|
||
if (Files.exists(binaryFile)) { | ||
FileAccess fileAccess = this.context.getFileAccess(); | ||
try { | ||
fileAccess.makeExecutable(binaryFile); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void installPlugin(PluginDescriptor plugin) { | ||
|
||
} | ||
} |
This file contains 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
This file contains 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
74 changes: 74 additions & 0 deletions
74
cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java
This file contains 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,74 @@ | ||
package com.devonfw.tools.ide.tool.androidstudio; | ||
|
||
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; | ||
|
||
/** | ||
* Test class for {@link AndroidStudio Android Studio IDE} tests. | ||
*/ | ||
public class AndroidStudioTest extends AbstractIdeContextTest { | ||
|
||
private static final String ANDROID_STUDIO = "android-studio"; | ||
|
||
private final IdeTestContext context = newContext(ANDROID_STUDIO); | ||
|
||
/** | ||
* Tests if {@link AndroidStudio Android Studio IDE} can be installed. | ||
* | ||
* @param os String of the OS to use. | ||
*/ | ||
@ParameterizedTest | ||
@ValueSource(strings = { "windows", "mac", "linux" }) | ||
public void testAndroidStudioInstall(String os) { | ||
// arrange | ||
SystemInfo systemInfo = SystemInfoMock.of(os); | ||
this.context.setSystemInfo(systemInfo); | ||
AndroidStudio commandlet = new AndroidStudio(this.context); | ||
|
||
// act | ||
commandlet.install(); | ||
|
||
// assert | ||
checkInstallation(this.context); | ||
} | ||
|
||
/** | ||
* Tests if {@link AndroidStudio Android Studio IDE} can be run. | ||
* | ||
* @param os String of the OS to use. | ||
*/ | ||
@ParameterizedTest | ||
@ValueSource(strings = { "windows", "mac", "linux" }) | ||
public void testAndroidStudioRun(String os) { | ||
// arrange | ||
SystemInfo systemInfo = SystemInfoMock.of(os); | ||
this.context.setSystemInfo(systemInfo); | ||
AndroidStudio commandlet = new AndroidStudio(this.context); | ||
|
||
// act | ||
commandlet.run(); | ||
|
||
// assert | ||
if (this.context.getSystemInfo().isMac()) { | ||
assertLogMessage(this.context, IdeLogLevel.INFO, ANDROID_STUDIO + " mac " + this.context.getWorkspacePath()); | ||
} else if (this.context.getSystemInfo().isLinux()) { | ||
assertLogMessage(this.context, IdeLogLevel.INFO, ANDROID_STUDIO + " linux " + this.context.getWorkspacePath()); | ||
} else if (this.context.getSystemInfo().isWindows()) { | ||
assertLogMessage(this.context, IdeLogLevel.INFO, ANDROID_STUDIO + " windows " + this.context.getWorkspacePath()); | ||
} | ||
|
||
checkInstallation(this.context); | ||
} | ||
|
||
private void checkInstallation(IdeTestContext context) { | ||
// commandlet - android-studio | ||
assertThat(context.getSoftwarePath().resolve("android-studio/.ide.software.version")).exists().hasContent("2024.1.1.1"); | ||
assertLogMessage(context, IdeLogLevel.SUCCESS, "Successfully installed android-studio in version 2024.1.1.1"); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/android-studio/project/settings/ide.properties
This file contains 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 @@ | ||
ANDROID-STUDIO_VERSION=2024.1.1.1 |
Empty file.
2 changes: 2 additions & 0 deletions
2
...jects/android-studio/repository/android-studio/android-studio/default/linux/bin/studio.sh
This file contains 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,2 @@ | ||
#!/bin/bash | ||
echo "android-studio linux $*" |
2 changes: 2 additions & 0 deletions
2
...ndroid-studio/android-studio/default/mac/Android Studio Preview.app/Contents/MacOS/studio
This file contains 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,2 @@ | ||
#!/bin/bash | ||
echo "android-studio mac $*" |
2 changes: 2 additions & 0 deletions
2
.../android-studio/repository/android-studio/android-studio/default/windows/bin/studio64.exe
This file contains 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,2 @@ | ||
#!/bin/bash | ||
echo "android-studio windows $*" |