Skip to content

Commit

Permalink
feat: use aqua for gradle
Browse files Browse the repository at this point in the history
Fixes #3889
  • Loading branch information
jdx committed Jan 1, 2025
1 parent 432a3e4 commit d0fdded
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ You can also specify the full name for a tool using `mise use aqua:1password/cli
| goss | [aqua:goss-org/goss](https://github.com/goss-org/goss) [asdf:raimon49/asdf-goss](https://github.com/raimon49/asdf-goss) |
| gotestsum | [aqua:gotestyourself/gotestsum](https://github.com/gotestyourself/gotestsum) [asdf:pmalek/mise-gotestsum](https://github.com/pmalek/mise-gotestsum) |
| graalvm | [asdf:asdf-community/asdf-graalvm](https://github.com/asdf-community/asdf-graalvm) |
| gradle | [asdf:rfrancis/asdf-gradle](https://github.com/rfrancis/asdf-gradle) [vfox:version-fox/vfox-gradle](https://github.com/version-fox/vfox-gradle) [aqua:gradle/gradle-distributions](https://github.com/gradle/gradle-distributions) |
| gradle | [aqua:gradle/gradle](https://github.com/gradle/gradle) [vfox:version-fox/vfox-gradle](https://github.com/version-fox/vfox-gradle) |
| gradle-profiler | [asdf:joschi/asdf-gradle-profiler](https://github.com/joschi/asdf-gradle-profiler) |
| grails | [asdf:weibemoura/asdf-grails](https://github.com/weibemoura/asdf-grails) |
| grain | [asdf:cometkim/asdf-grain](https://github.com/cometkim/asdf-grain) |
Expand Down
24 changes: 10 additions & 14 deletions registry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
1password.backends = ["asdf:NeoHsu/asdf-1password-cli", "aqua:1password/cli"]
# 1password.test = ["op --version", "{{version}}"] fails on CI for some reason
aapt2.backends = ["asdf:ronnnnn/asdf-aapt2"]
aapt2.test = ["aapt2 version", "Android Asset Packaging Tool (aapt)"]
aapt2.test = ["aapt2 version 2>&1", "Android Asset Packaging Tool (aapt)"]
act.backends = ["aqua:nektos/act", "ubi:nektos/act", "asdf:gr1m0h/asdf-act"]
act.test = ["act --version", "act version {{version}}"]
action-validator.backends = [
Expand Down Expand Up @@ -43,7 +43,7 @@ age-plugin-yubikey.backends = [
# test seems to fail on linux
# age-plugin-yubikey.test = ["age-plugin-yubikey --version", "age-plugin-yubikey {{version}}"]
agebox.backends = ["ubi:slok/agebox", "asdf:slok/asdf-agebox"]
agebox.test = ["agebox --version", "v{{version}}"]
agebox.test = ["agebox --version 2>&1", "v{{version}}"]
air.backends = ["aqua:air-verse/air", "asdf:pdemagny/asdf-air"]
air.test = ["air -v", "{{version}}"]
aks-engine.backends = [
Expand All @@ -56,7 +56,7 @@ allure.test = ["allure --version", "{{version}}"]
alp.backends = ["aqua:tkuchiki/alp", "asdf:asdf-community/asdf-alp"]
alp.test = ["alp --version", "{{version}}"]
amass.backends = ["ubi:owasp-amass/amass", "asdf:dhoeric/asdf-amass"]
amass.test = ["amass -version", "v{{version}}"]
amass.test = ["amass -version 2>&1", "v{{version}}"]
amazon-ecr-credential-helper.backends = [
"aqua:awslabs/amazon-ecr-credential-helper",
"asdf:dex4er/asdf-amazon-ecr-credential-helper"
Expand Down Expand Up @@ -298,7 +298,7 @@ choose.backends = [
]
chromedriver.backends = ["asdf:schinckel/asdf-chromedriver"]
cidr-merger.backends = ["ubi:zhanhb/cidr-merger", "asdf:ORCID/asdf-cidr-merger"]
cidr-merger.test = ["cidr-merger --version", "cidr merger {{version}}"]
cidr-merger.test = ["cidr-merger --version 2>&1", "cidr merger {{version}}"]
cidrchk.backends = ["ubi:mhausenblas/cidrchk", "asdf:ORCID/asdf-cidrchk"]
cidrchk.test = ["cidrchk --version", "{{version}},"]
cilium-cli.backends = [
Expand Down Expand Up @@ -741,7 +741,7 @@ gomigrate.backends = [
"aqua:golang-migrate/migrate",
"asdf:joschi/asdf-gomigrate"
]
gomigrate.test = ["migrate --version", "{{version}}"]
gomigrate.test = ["migrate --version 2>&1", "{{version}}"]
gomplate.backends = [
"aqua:hairyhenderson/gomplate",
"asdf:sneakybeaky/asdf-gomplate"
Expand All @@ -758,13 +758,9 @@ gotestsum.backends = [
"asdf:pmalek/mise-gotestsum"
]
graalvm.backends = ["asdf:asdf-community/asdf-graalvm"]
gradle.backends = [
"asdf:rfrancis/asdf-gradle",
"vfox:version-fox/vfox-gradle",
"aqua:gradle/gradle-distributions"
]
gradle.backends = ["aqua:gradle/gradle", "vfox:version-fox/vfox-gradle"]
gradle.depends = ["java"]
# gradle.test = ["gradle -V", "Gradle {{version}}"] TODO: make test-tool use dependencies
gradle.test = ["gradle -V", "Gradle"]
gradle-profiler.backends = ["asdf:joschi/asdf-gradle-profiler"]
grails.backends = ["asdf:weibemoura/asdf-grails"]
grain.backends = ["asdf:cometkim/asdf-grain"]
Expand Down Expand Up @@ -829,7 +825,7 @@ hls.backends = ["asdf:sestrella/asdf-ghcup"]
hostctl.backends = ["aqua:guumaster/hostctl", "asdf:svenluijten/asdf-hostctl"]
httpie-go.backends = ["aqua:nojima/httpie-go", "asdf:abatilo/asdf-httpie-go"]
httpie-go.os = ["linux", "macos"]
httpie-go.test = ["ht --version", "httpie-go {{version}}"]
httpie-go.test = ["ht --version 2>&1", "httpie-go {{version}}"]
hub.backends = ["aqua:mislav/hub", "asdf:mise-plugins/asdf-hub"]
hugo.backends = [
"aqua:gohugoio/hugo",
Expand Down Expand Up @@ -867,7 +863,7 @@ istioctl.test = ["istioctl version", "client version: {{version}}"]
janet.backends = ["asdf:Jakski/asdf-janet"]
java.backends = ["core:java"]
jb.backends = ["aqua:jsonnet-bundler/jsonnet-bundler", "asdf:beardix/asdf-jb"]
jb.test = ["jb --version", "v{{version}}"]
jb.test = ["jb --version 2>&1", "v{{version}}"]
jbang.backends = ["asdf:jbangdev/jbang-asdf"]
jfrog-cli.backends = ["asdf:LozanoMatheus/asdf-jfrog-cli"]
jib.backends = ["asdf:joschi/asdf-jib"]
Expand Down Expand Up @@ -1014,7 +1010,7 @@ kubent.backends = [
"aqua:doitintl/kube-no-trouble",
"asdf:virtualstaticvoid/asdf-kubent"
]
kubent.test = ["kubent --version", "version {{version}}"]
kubent.test = ["kubent --version 2>&1", "version {{version}}"]
kubergrunt.backends = [
"aqua:gruntwork-io/kubergrunt",
"asdf:NeoHsu/asdf-kubergrunt"
Expand Down
13 changes: 11 additions & 2 deletions src/cli/test_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,17 @@ impl TestTool {
}

fn test(&self, tool: &ToolArg, cmd: &str, expected: &str) -> Result<()> {
let mut args = vec![tool.clone()];
args.extend(
tool.ba
.backend()?
.get_all_dependencies(false)?
.into_iter()
.map(|ba| ba.to_string().parse())
.collect::<Result<Vec<ToolArg>>>()?,
);
let mut ts = ToolsetBuilder::new()
.with_args(&[tool.clone()])
.with_args(&args)
.with_default_to_latest(true)
.build(&Config::get())?;
let opts = InstallOptions {
Expand Down Expand Up @@ -144,7 +153,7 @@ impl TestTool {
} else {
cmd!("sh", "-c", cmd)
};
cmd = cmd.stderr_to_stdout().stdout_capture();
cmd = cmd.stdout_capture();
for (k, v) in env.iter() {
cmd = cmd.env(k, v);
}
Expand Down
7 changes: 4 additions & 3 deletions src/http.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::time::Duration;
Expand Down Expand Up @@ -174,14 +173,16 @@ impl Client {
}
}

file::create_dir_all(path.parent().unwrap())?;
let mut file = File::create(path)?;
let parent = path.parent().unwrap();
file::create_dir_all(parent)?;
let mut file = tempfile::NamedTempFile::with_prefix_in(path, parent)?;
while let Some(chunk) = resp.chunk().await? {
file.write_all(&chunk)?;
if let Some(pr) = pr {
pr.inc(chunk.len() as u64);
}
}
file.persist(path)?;
Ok::<(), eyre::Error>(())
})?;
Ok(())
Expand Down
19 changes: 17 additions & 2 deletions src/toolset/install_state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::backend::backend_type::BackendType;
use crate::cli::args::BackendArg;
use crate::file::display_path;
use crate::git::Git;
use crate::plugins::PluginType;
use crate::{dirs, file, runtime_symlinks};
use eyre::{Ok, Result};
Expand All @@ -9,7 +10,7 @@ use itertools::Itertools;
use rayon::prelude::*;
use std::collections::BTreeMap;
use std::ops::Deref;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use versions::Versioning;

Expand Down Expand Up @@ -55,7 +56,11 @@ fn init_plugins() -> MutexResult<InstallStatePlugins> {
.filter_map(|d| {
time!("init_plugins {d}");
let path = dirs::PLUGINS.join(&d);
if path.join("metadata.lua").exists() {
if is_banned_plugin(&path) {
info!("removing banned plugin {d}");
let _ = file::remove_all(&path);
None
} else if path.join("metadata.lua").exists() {
Some((d, PluginType::Vfox))
} else if path.join("bin").join("list-all").exists() {
Some((d, PluginType::Asdf))
Expand Down Expand Up @@ -128,6 +133,16 @@ pub fn list_plugins() -> Result<Arc<BTreeMap<String, PluginType>>> {
Ok(plugins)
}

fn is_banned_plugin(path: &Path) -> bool {
if path.ends_with("gradle") {
let repo = Git::new(path);
if let Some(url) = repo.get_remote_url() {
return url == "https://github.com/rfrancis/asdf-gradle.git";
}
}
false
}

pub fn get_tool_full(short: &str) -> Result<Option<String>> {
let tools = init_tools()?;
Ok(tools.get(short).and_then(|t| t.full.clone()))
Expand Down

0 comments on commit d0fdded

Please sign in to comment.