Import module as maven or gradle after creation

已回答

I created module builder in which user decides of project build tool - maven or gradle. Plugin downloads example maven or gradle files and unzip it to project build path.

After opening project I need to wait for IntelliJ to discover that it is maven project and click “Load maven project” on notification.

Is it possible to define project as Maven / Gradle to be automatically recognized as such by Intellij?

 

Tried below, but no luck:

override fun getProjectType(): ProjectType? {
    return ProjectType.create("maven" or "gradle")
}

 

Also tried:

override fun setupRootModel(modifiableRootModel: ModifiableRootModel) {
    val project = modifiableRootModel.project
    StartupManager.getInstance(project).runAfterOpened {
        ProjectUtil.openOrImport(project.basePath!!, project, true)
    }
}

But what it does is it opens second IntelliJ window (but with properly loaded maven project)

0

Hello!

Why do you need to define the project type? This abstraction cannot cover the mixed Gradle and Maven projects, because you can use different build systems in one project. Could see Gradle and Maven linked projects?

> Is it possible to define project as Maven / Gradle to be automatically recognized as such by Intellij?

You can try to evaluate project type after the opening or linking Gradle and Maven projects. You can use our auto-link machinery ExternalSystemUnlinkedProjectAware. (It is a notification in the right bottom corner that suggests you link the project with the detected build scripts)

> I need to wait for IntelliJ to discover that it is maven project and click “Load maven project” on notification.

You can use our new Observation API. It allows to wait for any Gradle and Maven project configuration activity (without preliminary project type identification). But it is available only since IDEA 2024.1.

ps. I don't recommend creating a new ModuleBuilder for the new project wizard implementation. Could you use the GeneratorNewProjectWizard with the GeneratorNewProjectWizardBuilderAdapter?

0

Hi, thanks for hint. I've started implementing GeneratorNewProjectWizard but it requires also to define project name, project location, used JDK and all StarterWizard helper classes are not in public API.

0

请先登录再写评论。