Use CloudRepo from IntelliJ IDEA
IntelliJ IDEA runs your Maven and Gradle builds, and CloudRepo is a Maven repository, so there is no CloudRepo setting in the IDE. Set up the build tool, then check that the IDE reads that setup. The same goes for the other JetBrains IDEs, which run the same two build tools.
Before you start
Section titled “Before you start”- A Maven repository. If you have none, create one.
- A repository token that reaches it. See Repository tokens. Your username is the email address of the account that created the token, and your password is the token.
- Your repository’s URL,
https://<organization>.mycloudrepo.io/repositories/<repository>.
Set up the build tool
Section titled “Set up the build tool”1. Put the credential in ~/.m2/settings.xml. The <id> is a name you choose, and the repository in
your pom.xml must use the same one. ${env.CLOUDREPO_TOKEN} reads the token from an environment
variable, so the file holds no token.
<settings> <servers> <server> <id>cloudrepo</id> <username>you@example.com</username> <password>${env.CLOUDREPO_TOKEN}</password> </server> </servers></settings>2. Name the repository in your pom.xml, to resolve dependencies from it and to publish to it. Pages
for both: Pull Maven artifacts and
Publish Maven artifacts.
3. Tell the IDE which settings file to read. Open Settings | Build, Execution, Deployment | Build
Tools | Maven and check the user settings file the IDE uses. It must be the settings.xml above.
4. Give the IDE the token. The IDE runs Maven in its own environment, and ${env.CLOUDREPO_TOKEN}
is read from there. A program sees the environment variables of the process that started it, so an IDE
started from a launcher does not see a variable you exported in a terminal. Either start the IDE from the
shell that exports the variable, or set it for the IDE’s Maven runs under Maven | Runner | Environment
variables.
1. Keep the credential in ~/.gradle/gradle.properties, outside your project, so it is never
committed. The username is your email address, and the password is the token.
cloudrepoUsername=you@example.comcloudrepoToken=YOUR_REPOSITORY_TOKEN2. Read it in your build script, to resolve dependencies from CloudRepo and to publish to it. Pages for both: Pull Gradle dependencies and Publish Gradle artifacts.
3. Check the Gradle user home the IDE uses. Gradle reads gradle.properties from its user home,
~/.gradle unless the environment variable GRADLE_USER_HOME says otherwise. IntelliJ shows the Gradle
user home it uses under Settings | Build, Execution, Deployment | Gradle. It must be the directory
that holds the file above.
Check it from the IDE
Section titled “Check it from the IDE”Run a build that needs CloudRepo from the IDE’s Maven or Gradle tool window: resolve a dependency
from your repository, or run deploy (Maven) or publish (Gradle) to publish. If the same build works in
a terminal and fails in the IDE, the IDE is not reading the file or the variable you set up above: check
the settings named on this page, and that you restarted the IDE after changing an environment
variable.
If the build fails with a status, the cause is the one the build tool’s page lists, and it is the same in the IDE. See “When Maven answers 401, 403 or 404” on Pull Maven artifacts, “When Gradle answers 401, 403 or 404” on Pull Gradle dependencies, and the matching list on each publish page.
A TLS error
Section titled “A TLS error”CloudRepo serves *.mycloudrepo.io with a publicly trusted certificate, so neither the IDE nor its JDK
needs a certificate imported to trust it. If your network terminates TLS at a corporate proxy, the
certificate the IDE sees is the proxy’s, and the proxy’s certificate authority must be trusted by the JDK
the IDE runs on. See JetBrains’ documentation for the IDE’s certificate settings.
More: Repository tokens, for every client’s credential; Proxy repositories, to resolve Maven Central through CloudRepo; and the JetBrains documentation for Maven and for Gradle.