如何在Idea模块中使用gradle设置scala sdk? [英] How do I set the scala sdk using gradle in Idea module?

查看:265
本文介绍了如何在Idea模块中使用gradle设置scala sdk?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的build.gradle文件

My build.gradle file

idea {
    project {
        vcs {
            vcs = 'Git'
        }

        jdkName = '1.8'
        languageLevel = '1.8'
    }
}

我还想使用gradle在模块中设置scala SDK. 现在,我最终不得不从Idea UI的Project Structure中手动设置它. 理想情况下,我希望将其设置在build.gradle文件中,以便在运行时

I would also like to set the scala SDK in the module using gradle. Right now, I end up having to manually set it from Project Structure in the Idea UI. Ideally, I would prefer to set it in my build.gradle file such that when I run

毕业想法

为此模块自动设置了scala SDK

the scala SDK is automatically set for this module

推荐答案

要使用gradle在Intellij中使用带有scala模块的项目,

To have a project with scala module in Intellij using gradle,

  1. 创建一个新的IDEA based scala project
  2. 给出适当的项目名称并继续.
  3. 接下来,检查您是否在本地环境中学习了. (使用$sudo apt install gradle安装gradle,然后使用命令$which gradle查找gradle的位置)
  4. 打开您的终端并导航到您的项目目录.执行命令$gradle init --type scala-library 这将使您的项目基于gradle,并且您将在Intellij中看到相关的gradle文件.
  5. 重新启动Intellij并导航到View > Tool Windows > Gradle以查看Gradle选项卡.
  1. Create a new IDEA based scala project
  2. Give appropriate project name and proceed.
  3. Next, check if you've gradle in your local environment. (Install gradle using $sudo apt install gradle and then use command $which gradle to find location of gradle)
  4. Open your terminal and navigate to your project directory. Execute command $gradle init --type scala-library This will make your project gradle based and you'll see associated gradle files in Intellij.
  5. Restart Intellij and navigate to View > Tool Windows > Gradle to see Gradle tab.

这篇关于如何在Idea模块中使用gradle设置scala sdk?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆