知乎专栏 |
Homebrew 最初是为 Mac 设计的包管理工具,现在已经移植到了Linux系统。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
国内镜像安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
运行下面命令,让brew生效
source /Users/neo/.zprofile neo@MacBook-Pro-M2 ops % git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core neo@MacBook-Pro-M2 ops % git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
brew install openjdk@8 sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk
配置 Maven
Neo-iMac:~ neo$ brew info maven maven: stable 3.8.3 (bottled) Java-based project management https://maven.apache.org/ Conflicts with: mvnvm (because also installs a 'mvn' executable) /usr/local/Cellar/maven/3.8.3 (79 files, 10MB) * Poured from bottle on 2021-11-08 at 14:04:51 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/maven.rb License: Apache-2.0 ==> Dependencies Required: openjdk ✔ ==> Analytics install: 63,168 (30 days), 200,658 (90 days), 634,767 (365 days) install-on-request: 62,864 (30 days), 199,051 (90 days), 630,240 (365 days) build-error: 0 (30 days)
找到 /usr/local/Cellar/maven/3.8.3 文件夹
Neo-iMac:~ neo$ vim /usr/local/Cellar/maven/3.8.3/libexec/conf/settings.xml 屏蔽下面配置 <mirror> <id>maven-default-http-blocker</id> <mirrorOf>external:http:*</mirrorOf> <name>Pseudo repository to mirror external repositories initially using HTTP.</name> <url>http://0.0.0.0/</url> <blocked>true</blocked> </mirror>
例如安装了多个版本的工具
Neo-iMac:~ neo$ brew install gradle Neo-iMac:~ neo$ brew install gradle@6
默认是最新版切换到6版本方法
Neo-iMac:~ neo$ brew unlink gradle Neo-iMac:~ neo$ brew link gradle@6
Neo-iMac:~ neo$ gradle -v Welcome to Gradle 6.9.2! Here are the highlights of this release: - This is a small backport release. - Java 16 can be used to compile when used with Java toolchains - Dynamic versions can be used within plugin declarations - Native support for Apple Silicon processors For more details see https://docs.gradle.org/6.9.2/release-notes.html ------------------------------------------------------------ Gradle 6.9.2 ------------------------------------------------------------ Build time: 2021-12-21 20:18:38 UTC Revision: 5d94aa68c0fdbe443838bb977080e3b9f273e889 Kotlin: 1.4.20 Groovy: 2.5.12 Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020 JVM: 11.0.16.1 (Homebrew 11.0.16.1+0) OS: Mac OS X 12.5 x86_64