Как импортировать проект в intellij idea
Перейти к содержимому

Как импортировать проект в intellij idea

  • автор:

Как правильно импортировать проект в Intellij IDEA?

Решил я значит поменять стек с c# на Java и немного удивился от работы местных авто сборщиков пакетов, модульности и так далее (в хорошую сторону). Как мне кажется разобрался с инструментами, понял общую схему работы модулей и пакетов, и что сейчас важно для меня — maven.

Есть два проекта:
simpleexcel.api и simpleexcel.api.tests

5c33492d01b78139698441.png

Первый — api — restfull сервис на основе RESTEasy (Wildfly 15.0), которая импортируется как библиотека без проблем, все работает. На выходе при сборке пакета — war’ник, который в последствии загружается на WildFly 15.0, все работает без проблем. (Точки входа в программе, как таковой нет — с jar проблема)

pom.xml

  4.0.0 SimpleExcel.Api simpleexcel.api SimpleExcel.Api 1.0-SNAPSHOT war 1.8 1.8 UTF-8 false    org.jboss.resteasy jaxrs-api 3.0.12.Final provided   --> ROOT--> -->     maven-clean-plugin 3.1.0   maven-resources-plugin 3.0.2  maven-compiler-plugin 3.8.0  maven-surefire-plugin 2.22.1  maven-jar-plugin 3.0.2  maven-install-plugin 2.5.2  maven-deploy-plugin 2.8.2  maven-project-info-reports-plugin 3.0.0  maven-assembly-plugin 3.1.0  org.apache.maven.plugins maven-jar-plugin     

Второй — api.tests — тесты для апи. Тут мне нужно импортировать классы из первого проекта, чтобы я мог создавать их экземпляры и тестировать методы внутренних сервисов.

5c33527c7f8a5620068555.png

pom.xml

  4.0.0 SimpleExcel.Api.Tests SimpleExcel.Api.Tests 1.0-SNAPSHOT SimpleExcel.Api.Tests UTF-8 1.8 1.8   junit junit 4.11 test       maven-clean-plugin 3.1.0   maven-resources-plugin 3.0.2  maven-compiler-plugin 3.8.0  maven-surefire-plugin 2.22.1  maven-jar-plugin 3.0.2  maven-install-plugin 2.5.2  maven-deploy-plugin 2.8.2   maven-site-plugin 3.7.1  maven-project-info-reports-plugin 3.0.0     

В Intellij IDEA я пытаюсь импортировать модуль simpleexcel.api из simpleexcel.api в simpleexcel.api.tests и при импорте, IDEA находит почему то только main и именно пустой.

Объясните, что я делаю не так? (Добавляю я в зависимостях)
Возможно у вас есть тестовый проект где есть подобная ситуация? Какая должна быть правильная последовательность действий? (Я же могу импортировать модуль без сборки? Т.е просто классы)

  • Вопрос задан более трёх лет назад
  • 4498 просмотров

Import and export projects

This option imports the selected project to IntelliJ IDEA as is (opens it). If you want to set custom settings while importing the project (for example, select another SDK or choose the libraries that you want to import), refer to Create a project from existing sources.

Dialog that prompts you to select how you want to import the project

  1. Launch IntelliJ IDEA. If the Welcome screen opens, click Open . Otherwise, go to File | Open .
  2. In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open .
  3. When you import or clone a project for the first time, IntelliJ IDEA analyzes it. If the IDE detects more than one configuration (for example, Eclipse and Gradle), it prompts you to select which configuration you want to use. If the project that you are importing uses a build tool, such as Maven or Gradle, we recommend that you select the build tool configuration. Select the necessary configuration and click OK . The IDE pre-configures the project according to your choice. For example, if you select Gradle , IntelliJ IDEA executes its build scripts, loads dependencies, and so on.
  4. If you have been working with another project, select whether you want to open the new project in a new dialog or in the current one.

For more information about getting a project from version control, refer to Check out a project from a remote host (git clone).

Import a project with settings

This section describes the functionality that is available out of the box. If you are using a framework plugin, refer to the corresponding documentation section.

Import a project from an external model

Use this type of import if your project comes from an external model, and you want to import it as a whole. In this case, IntelliJ IDEA interprets the project files (for example, your Eclipse project will be migrated to IntelliJ IDEA).

  1. Launch IntelliJ IDEA. If the Welcome screen opens, press Control+Shift+A , type project from existing sources , and click the Import project from existing sources action in the popup. Otherwise, go to File | New | Project from Existing Sources . Importing a project from existing sources
  2. In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open .
  3. Select the external model that your project uses:
    • Eclipse
    • Maven
    • Gradle: select the necessary build tool and click Finish . For Maven and Gradle projects, the IDE configures the settings automatically. You will be able to adjust them after the project is imported.

    Importing a project from an external model

Create a project from existing sources

Use this type of import to create an IntelliJ IDEA project over the existing source code that is not necessarily an exported project.

  1. Launch IntelliJ IDEA. If the Welcome screen opens, press Control+Shift+A , type project from existing sources , and click the Import project from existing sources action in the popup. Otherwise, go to File | New | Project from Existing Sources . Importing a project from existing sources
  2. In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open .
  3. Select the Create project from existing sources option and click Next . Creating a project from existing sources
  4. Specify the name and location and select a format for the new project. It’s recommended that you use the directory-based format. Click Next . If you are importing the project to the same directory, the IDE asks you whether you want to overwrite it. If you click Yes , IntelliJ IDEA will overwrite the files in .idea directory and the .iml files, your source files will remain intact. A popup warning you that the folder will be overwritten
  5. Select the directories that you want to use as source root directories (folders with your source code) and click Next . Importing sources
  6. Select the libraries that you want to add to the new project. You can join several selected libraries or archives into a new library by clicking or split the selected library into two by clicking . Click Next Importing libraries
  7. Review module structure: select the modules that you want to include in your project. You can merge several modules into one by clicking or split the selected module into two by clicking . Click Next
  8. Specify the SDK that you want to use. If the necessary SDK is already defined in IntelliJ IDEA, select it from the list on the left. Otherwise, click and add a new SDK. Click Next . Importing SDK
  9. Enable support for the detected frameworks and technologies: select checkboxes next to the necessary items. You can also specify how the files-indicators should be grouped: by type (by framework) or by directory (by location).
  10. Click Finish .

Export a project

You can save a project as a .zip archive or export it to Eclipse.

Save a project as a .zip file

The option to export a project to a .zip file is available if the Android bundled plugin is enabled.

  1. Go to File | Export | Project to Zip File .
  2. In the dialog that opens, specify the path to which you want to save the .zip file with the project and click Save .

Your project will be saved to the specified location as a .zip archive.

Как поместить проект из архива в среду intellij idea?

Для начала, проект, который упакован в архив, надо распаковать в какое то удобное место. Для IDEA таким местом может быть папка с проектами этой IDE назначенная ей по умолчанию. Далее:

  1. Если этот проект ранее был подготовлен в среде IntelliJ IDEA, то просто открываете его (если в IDE открыт другой проект): File -> Open

screen

То же самое можно сделать и со стартового экрана IDEA, когда никакой проект еще не открыт: 3-тий пункт — Open:

В появившемся окне указываете путь до корневой папки проекта.

  1. Если проект подготовлен в другой IDE (написан в блокноте), его надо импортировать, чтобы IDEA могла создать свои рабочие файлы и каталоги:

File -> New -> Project from Existing Sources ..

На стартовом экране это второй пункт — Import Project

В появившемся окне необходимо указать путь до корневой папки проекта. Далее следовать указаниям мастера, так как в зависимости от того, на чем основан проект (Maven, gradle, ant и тд.) требуются разные действия.

Настройка IntelliJ IDEA

Эта статья рассказывает о том, как настроить Ваше рабочее пространство IntelliJ IDEA для разработки плагинов со SpongeAPI и :doc: создавать системы, такие как Maven или Gradle `.

Gradle

Создание проекта

  • Откройте IntelliJ IDEA.
  • Нажмите Create New Project .
  • Выберите Gradle в появившемся окне и нажмите кнопку Next .
  • Введите Ваши Group ID, Artifact ID, и Version.
    • Group ID обычно должен соответствовать названию Вашего пакета Java. Для подробностей смотрите Основной класс плагина .
    • Artifact ID обычно должен соответствовать Вашему plugin ID, который задавался Вами ранее, например myplugin .
    • Version — версия проекта, зависит только от Вас.

    Редактирование build-скрипта

    • Откройте build.gradle в навигаторе и добавьте зависимости.
    • Отредактируйте build-скрипт, как описано в статье Настройка Gradle .
    • Откройте Gradle tab в правой части окна программы и нажмите кнопку обновления (refresh).
    • Установка Gradle завершена! Теперь Вы можете приступить к написанию кода Вашего плагина.

    Импорт Вашего проекта

    Если вы уже начали работу с вашим проектом и хотите снова импортировать его позже, вам необходимо его импортировать вместо повторного создания внутри вашей IDE:

    • Нажмите File > Open
    • Перейдите к файлу проекта build.gradle
    • Нажмите Ok

    Maven

    Создание проекта

    • Откройте IntelliJ IDEA.
    • Нажмите Create New Project .
    • Выберите Maven в появившемся окне и нажмите Next .
    • Введите Ваши Group ID, Artifact ID, и Version.
      • Group ID обычно должен соответствовать названию Вашего пакета Java. Для подробностей смотрите Основной класс плагина .
      • Artifact ID обычно должен соответствовать Вашему plugin ID, который задавался Вами ранее, например myplugin .
      • Version — версия проекта, зависит только от Вас.

      Редактирование конфигурации проекта

      • Откройте pom.xml в навигаторе.
      • Отредактируйте build-скрипт, как описано в статье Настройка Maven .
      • Обновите Ваш проект Maven.
      • Импортируйте изменения Maven, если появилась подсказка.

      Импорт Вашего проекта

      Если вы уже начали работу с вашим проектом и хотите снова импортировать его позже, вам необходимо его импортировать вместо повторного создания внутри вашей IDE:

      • Нажмите File > Open
      • Перейдите к файлу проекта pom.xml
      • Нажмите Ok

      Git Интеграция

      JetBrains предлагает документацию по интеграции Git:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *