Skip to content

Commit

Permalink
devonfw#991: Introduce dependencies.json for gradle
Browse files Browse the repository at this point in the history
Fixes devonfw#991
Removed method "installDependencies
Added test-json dependencies.json
Added GradleTest and necessary resources
Changed permissions to git execute in files
  • Loading branch information
hj-lorenz committed Jan 30, 2025
1 parent 5300a96 commit 8f788de
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
import com.devonfw.tools.ide.tool.java.Java;

/**
* {@link ToolCommandlet} for <a href="https://gradle.org/">gradle</a>.
Expand All @@ -23,13 +22,6 @@ public Gradle(IdeContext context) {
super(context, "gradle", Set.of(Tag.JAVA, Tag.BUILD));
}

@Override
protected void installDependencies() {

// TODO create gradle/gralde/dependencies.json file in ide-urls and delete this method
getCommandlet(Java.class).install();
}

@Override
public String getToolHelpArguments() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.devonfw.tools.ide.tool.gradle;

import java.io.IOException;

import org.junit.jupiter.api.Test;

import com.devonfw.tools.ide.commandlet.InstallCommandlet;
import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;

/**
* Integration test of {@link Gradle}.
*/
public class GradleTest extends AbstractIdeContextTest {

//*insert

private static final String PROJECT_GRADLE = "gradle";
private static final String GRADLE_VERSION = "8.7";

/**
* Tests the installation of {@link Gradle}
*
* @throws IOException if an I/O error occurs during the installation process
*/
@Test
public void testgradleInstall() throws IOException {

// arrange
IdeTestContext context = newContext(PROJECT_GRADLE);
InstallCommandlet install = context.getCommandletManager().getCommandlet(InstallCommandlet.class);
install.tool.setValueAsString("gradle", context);

// act
install.run();

// assert
checkInstallation(context);
}

/**
* Tests the execution of {@link Gradle}
*
* @throws IOException if an I/O error occurs during the installation process
*/
@Test
public void testGradleRun() throws IOException {
// arrange
IdeTestContext context = newContext(PROJECT_GRADLE);
InstallCommandlet install = context.getCommandletManager().getCommandlet(InstallCommandlet.class);
install.tool.setValueAsString("gradle", context);
Gradle commandLet = (Gradle) install.tool.getValue();
commandLet.arguments.addValue("foo");
commandLet.arguments.addValue("bar");

// act
commandLet.run();

// assert
assertThat(context).logAtInfo().hasMessage("gradle " + "foo bar");
checkInstallation(context);
}

private void checkInstallation(IdeTestContext context) throws IOException {

assertThat(context.getSoftwarePath().resolve("java/bin/java")).exists();

assertThat(context.getSoftwarePath().resolve("gradle/.ide.software.version")).exists().hasContent(GRADLE_VERSION);
assertThat(context).logAtSuccess().hasMessage("Successfully installed gradle in version " + GRADLE_VERSION);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"[8.5,8.8)": [
{
"tool": "java",
"versionRange": "[17,)"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"[8.5,8.8)": [
{
"tool": "java",
"versionRange": "[17,)"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${testbaseurl}/download/gradle/gradle/8.7/gradle-8.7.tgz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${testbaseurl}/download/java/java/17.0.10_7/java-17.0.10_7.tgz
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JAVA_VERSION=17.0.10_7
GRADLE_VERSION=8.7
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "gradle $*"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo java $*

0 comments on commit 8f788de

Please sign in to comment.