Skip to content
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

#12: Implement ToolCommandlet for Android Studio #299

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
686f27a
#12: added Android Studio IDE
jan-vcapgemini Apr 17, 2024
79b8c84
#12: inversed OS checks
jan-vcapgemini Apr 18, 2024
fe6feae
adjusted .gitattributes
jan-vcapgemini Apr 22, 2024
136a20d
fixed line endings
jan-vcapgemini Apr 22, 2024
c252306
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Apr 22, 2024
f4171e4
#12: added test + resources
jan-vcapgemini Apr 22, 2024
590a40d
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Apr 22, 2024
46ce1f9
#12: removed symlink creation
jan-vcapgemini Apr 22, 2024
a32cb19
#12: cleanup
jan-vcapgemini Apr 23, 2024
4acb2e7
#12: added proper MacOS implementation
jan-vcapgemini Apr 23, 2024
c4f32a3
#12: fixed extractDmg
jan-vcapgemini Apr 24, 2024
e135fda
#12: cleanup and fix open
jan-vcapgemini Apr 24, 2024
d6ada24
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Apr 25, 2024
0b48221
#12: cleanup and fixes
jan-vcapgemini Apr 25, 2024
eedf62a
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Apr 29, 2024
8d26469
#12: implemented requested change
jan-vcapgemini Apr 29, 2024
2efa498
#12: applied optimizations
jan-vcapgemini Apr 30, 2024
170c834
#12: re-added file permission setter
jan-vcapgemini May 3, 2024
aae698d
#12: fixed tests
jan-vcapgemini May 3, 2024
b50ed40
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini May 3, 2024
6f14628
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini May 7, 2024
43520de
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini May 8, 2024
01f4fde
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
hohwille May 17, 2024
434bb4e
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini May 21, 2024
09952d6
Merge branch 'feature/12-implement-androidstudio-commandlet' of https…
jan-vcapgemini May 21, 2024
63e9a24
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini May 28, 2024
b6396e3
#12: added documentation file
jan-vcapgemini May 30, 2024
2639f51
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini May 30, 2024
bffb920
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Jul 3, 2024
92b0150
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Jul 5, 2024
ef61d5d
#12: applied changes from intellij
jan-vcapgemini Jul 5, 2024
bf413aa
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Jul 5, 2024
f387f3b
#12: added detailed help
jan-vcapgemini Jul 5, 2024
36bf78d
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Jul 8, 2024
4382b43
#12: removed documentation
jan-vcapgemini Jul 8, 2024
0ecd27e
#25: added missing binary
jan-vcapgemini Jul 8, 2024
1c13eb8
Merge branch 'main' into feature/12-implement-androidstudio-commandlet
jan-vcapgemini Jul 11, 2024
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

# special handling for test files
studio64.exe text
idea64.exe text
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.property.KeywordProperty;
import com.devonfw.tools.ide.property.Property;
import com.devonfw.tools.ide.tool.androidstudio.AndroidStudio;
import com.devonfw.tools.ide.tool.aws.Aws;
import com.devonfw.tools.ide.tool.az.Azure;
import com.devonfw.tools.ide.tool.cobigen.Cobigen;
Expand Down Expand Up @@ -105,6 +106,7 @@ public CommandletManagerImpl(IdeContext context) {
add(new Jasypt(context));
add(new Docker(context));
add(new Sonar(context));
add(new AndroidStudio(context));
add(new GraalVm(context));
add(new PgAdmin(context));
add(new LazyDocker(context));
Expand Down
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) {

}
}
2 changes: 2 additions & 0 deletions cli/src/main/resources/nls/Help.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmd.--version=Print the version of IDEasy.
cmd.--version.detail=TODO --version
cmd.android-studio=Tool commandlet for Android Studio (IDE).
cmd.android-studio.detail=The android-studio commandlet allows to install, configure, and launch Android Studio. To launch Android Studio for your current workspace and IDEasy installation, simply run: ide android-studio. Detailed documentation can be found at https://developer.android.com/studio/.
cmd.aws=Tool commandlet for AWS CLI.
cmd.aws.detail=The AWS Command Line Interface (AWS CLI) is an open source tool for managing AWS resources. Detailed documentation can be found at https://docs.aws.amazon.com/cli/
cmd.az=Tool commandlet for Azure CLI.
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
@@ -1,5 +1,7 @@
cmd.--version=Gibt die Version von IDEasy aus.
cmd.--version.detail=TODO DE --version
cmd.android-studio=Werkzeug Kommando für Android Studio (IDE).
cmd.android-studio.detail=Das android-studio Kommando ermöglicht die Installation, Konfiguration und den Start von Android Studio. Um Android Studio für Ihren aktuellen Arbeitsbereich und die IDEasy-Installation zu starten, führen Sie einfach: 'ide android-studio' aus. Detaillierte Dokumentation finden Sie unter https://developer.android.com/studio/.
cmd.aws=Werkzeug Kommando für AWS Kommandoschnittstelle.
cmd.aws.detail=Das AWS Command Line Interface (AWS CLI) ist ein Open-Source-Werkzeug zur Verwaltung von AWS Ressourcen. Detaillierte Dokumentation ist zu finden unter https://docs.aws.amazon.com/cli/
cmd.az=Werkzeug Kommando für Azure Kommandoschnittstelle.
Expand Down
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");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ANDROID-STUDIO_VERSION=2024.1.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "android-studio linux $*"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "android-studio mac $*"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "android-studio windows $*"
Loading