java-samples icon indicating copy to clipboard operation
java-samples copied to clipboard

Failed message when importing into IntelliJ

Open axeddie opened this issue 5 years ago • 0 comments
trafficstars

(Please fill out these details before submitting an issue)

Sample Name

settings.gradle file error

Expected Behavior

Basic project imports as gradle project without errors.

Actual Behavior

I get this error: Project directory 'C:_N4\Dev\myWidgets' is not part of the build defined by settings file 'C:_N4\Dev\settings.gradle'. If this is an unrelated build, it must have its own settings file.

Specifications

  • Java version (java -version) java version "1.8.0_241" Java(TM) SE Runtime Environment (build 1.8.0_241-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

  • OS (Mac/Linux/Windows) Windows 10, 64bit

Hi,

After building a folder structure (which is done through a third-part software and thus has some gradle files added at first) I import to IntelliJ as a gradle project and I get this error:

Project directory 'C:_N4\Dev\myWidgets' is not part of the build defined by settings file 'C:_N4\Dev\settings.gradle'. If this is an unrelated build, it must have its own settings file.

This is the settings file under my "Dev" directory:

/* Copyright 2020 OTI, All Rights Reserved. */

import groovy.io.FileVisitResult import groovy.io.FileType

def discoveredProjects = [:] as Map<String, File>

ext { // CONFIGURE your sub-project folders here. // This will include ALL sub-folders as sub-projects. niagaraRoots = ['.'] // To explicitly define sub-project folders, name them in the array like this //niagaraRoots = ['componentLinks', 'envCtrlDriver'] //niagaraRoots = ['myFirstModule-ux']

// CONFIGURE any directories to exclude from search for nested sub-projects excludeDirs = ['.hg', 'build', 'out', 'src', 'srcTest'] }

// OR set the 'userRepos' gradle property. // if (hasProperty('userRepos')) { settings.ext.niagaraRoots += userRepos.split(",").collect() }

// my-settings.gradle. // def mySettings = file('my-settings.gradle') if (mySettings.exists()) { apply from: mySettings }

def environment = file('environment.gradle') if (environment.exists()) { apply from: environment }

// DO NOT MODIFY the niagaraRoots configuration niagaraRoots.collect({ file(it) }).findAll({ it.exists() }).each { File projectRoot -> projectRoot.traverse( type: FileType.DIRECTORIES, preRoot: true, preDir: { File projectDir -> def projectName = projectDir.name if (excludeDirs.contains(projectName)) { return FileVisitResult.SKIP_SUBTREE }

  File buildScript = new File(projectDir, "${projectName}.gradle")
  if (buildScript.exists()) {
    discoveredProjects[projectName] = projectDir
    include projectName
    return FileVisitResult.SKIP_SUBTREE
  }
}

) }

// Can we change the rootproject.name? rootProject.name = 'niagara' rootProject.children.each { project -> project.projectDir = discoveredProjects[project.name] project.buildFileName = "${project.name}.gradle" assert project.projectDir.isDirectory() assert project.buildFile.isFile() }

Could the error be because some gradle files already existed?

THanks

axeddie avatar Mar 30 '20 18:03 axeddie