Skip to content

Conversation

@cthies-capgemini
Copy link
Contributor

@cthies-capgemini cthies-capgemini commented Aug 27, 2025

This PR fixes #1166 .

Implemented changes:

For Maven:

  • Maven projects are detected by the presence of a pom.xml file
  • misc.xml is created if it does not exist
  • it is then merged with another misc.xml file declaring a MavenProjectManager component
  • this file currently needs to to placed under settings/templates/conf/mvn/misc.xml but this can be changed easily
  • the path to the pom.xml file is currently hard-coded in there, it would probably be better to automatically fill this with the path detected in the beginning

This is the current content of the template misc.xml:

<project version="4" xmlns:merge="https://github.com/devonfw/IDEasy/merge">
<component name="MavenProjectsManager">
    <option name="originalFiles">
      <list>
        <option value="$PROJECT_DIR$/IDEasy/pom.xml"/>
      </list>
    </option>
  </component>
</project>

For Gradle

  • Gradle works similar to Maven
  • IDEasy detects the presence of a build.gradle or a build.gradle.kts file for java or kotlin projects respectively
  • It creates a gradle.xml file in .idea if it doesn't exist yet
  • It is then merged with another gradle.xml file that declares the GradleProjectSettings
  • this file currently needs to to placed under settings/templates/conf/gradle/gradle.xml but this can be changed easily
  • Like the pom.xml, the path here should be automatically filled by replacing the project name

Implementations by @jan-vcapgemini:

  • extended ExtensibleEnvironmentVariables from EnvironmentVariablesMap
  • added findAncestorWithFolder to FileAccess
  • added findAncestorWithFolder
  • added tests of findAncestorWithFolder to FileAccessImplTests
  • added test of intellij project import to IntellijTest
  • added test resources to simulate a repository import of intellij
  • added createValidEmptyXmlFile to XmlMerger (to be able to handle missing files)
  • removed temporary workaround in Intellij for the creation of an empty xml file

This is the current content of the template gradle.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4" xmlns:merge="https://github.com/devonfw/IDEasy/merge">
  <component name="GradleMigrationSettings" migrationVersion="1" />
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="externalProjectPath" value="$PROJECT_DIR$/gradleSample" />
      </GradleProjectSettings>
    </option>
  </component>
</project>

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal

@github-project-automation github-project-automation bot moved this to 🆕 New in IDEasy board Aug 27, 2025
@jan-vcapgemini jan-vcapgemini added mvn related to apache maven build tool intellij IntelliJ IDE from Jet-Brains labels Sep 1, 2025
@jan-vcapgemini jan-vcapgemini moved this from 🆕 New to Team Review in IDEasy board Sep 1, 2025
@coveralls
Copy link
Collaborator

coveralls commented Sep 3, 2025

Pull Request Test Coverage Report for Build 19833443579

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 73 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.2%) to 70.042%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/io/FileAccess.java 1 93.62%
com/devonfw/tools/ide/tool/gradle/Gradle.java 1 88.89%
com/devonfw/tools/ide/tool/intellij/Intellij.java 7 82.72%
com/devonfw/tools/ide/merge/xml/XmlMerger.java 14 80.48%
com/devonfw/tools/ide/io/FileAccessImpl.java 50 67.32%
Totals Coverage Status
Change from base Build 19833342865: 0.2%
Covered Lines: 9880
Relevant Lines: 13572

💛 - Coveralls

@cthies-capgemini
Copy link
Contributor Author

Gradle projects are automatically imported if a valid gradle.xml file is found in .idea. I'll follow the same approach as for the misc.xml to automatically create / update this file if a build.gradle file is found.

@cthies-capgemini cthies-capgemini marked this pull request as ready for review September 23, 2025 11:56
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cthies-capgemini thanks for your PR. Great that you found the proper solutions to import projects for maven and gradle. Also your implementation is looking good. 👍
However, I found some things that need further improvements before we can merge.
Also it would be great to always have a JUnit for each relevant feature we add.

…EnvironmentVariables.java

Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>
jan-vcapgemini and others added 3 commits November 17, 2025 16:20
added constants and replaced fixed strings
enhanced debug messages with missing file paths
refactored mergeMisc and mergeGradle into mergeConfig method
jan-vcapgemini and others added 4 commits November 25, 2025 13:54
extended ExtensibleEnvironmentVariables from EnvironmentVariablesMap
added findAncestoryWithFolder to FileAccess
added findAncestoryWithFolder
added tests of findAncestoryWithFolder to FileAccessImplTests
added test of intellij project import to IntellijTest
added test resources to simulate a repository import of intellij
added createValidEmptyXmlFile to XmlMerger (to be able to handle missing files)
removed temporary workaround in Intellij for the creation of an empty xml file
@jan-vcapgemini jan-vcapgemini added the enhancement New feature or request label Nov 25, 2025
@hohwille
Copy link
Member

hohwille commented Dec 9, 2025

Replaced by PR #1649

@hohwille hohwille closed this Dec 9, 2025
@github-project-automation github-project-automation bot moved this from Team Review to ✅ Done in IDEasy board Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gradle Gradle build tool intellij IntelliJ IDE from Jet-Brains mvn related to apache maven build tool repository Commandlet to clone, build or import git repositories

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Automatic project import for IntelliJ

4 participants