Skip to content

Commit 4f6e9f4

Browse files
committed
feat(OSX Support): Support IDEA launch w/ support by @mbuhot
Closes #1
2 parents 02efb3d + 2135fcc commit 4f6e9f4

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

.ideainspect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
levels: WARNING,ERROR,INFO
33

44
# Inspection result files to skip. For example "TodoComment" or "TodoComment.xml".
5-
skip: TodoComment,Annoatator
5+
skip: TodoComment,Annotator
66

77
# Ignore issues affecting source files matching given regex. Example ".*/generated/.*".
88
skipfile: .*/generated/.*,src/main/Foo.java
@@ -11,7 +11,7 @@ skipfile: .*/generated/.*,src/main/Foo.java
1111
resultdir: target/inspection-results
1212

1313
# IDEA installation home directory. Default: IDEA_HOME environment variable or "idea".
14-
ideahome: /home/ben/devel/idea
14+
# ideahome: /home/ben/devel/idea
1515

1616
# Limit IDEA inspection to this directory
1717
# dir: .

CHANGES.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[cols="1,5", options="header"]
44
|===
55
| Version | Change
6+
| 1.3 | Support for Mac OSX locations of IntelliJ IDEA executables +
67
| 1.2 | Add support for configuration file +
78
Add debugging flag `-v` +
89
Replaced all mandatory CLI options with default values (root directory, IDEA home, Inspection profile name, ...)

README.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ the "Root JDK".
200200

201201
To fix this error simply assign every module a SDK other than "Project SDK".
202202

203+
.What shall I pass as IDEA home directory for Mac OSX?
204+
205+
`/Applications/IntelliJ\ IDEA.app` should be the default installation folder.
206+
207+
203208
== Source code & Contributions
204209

205210
The source code is located under https://github.com/bentolor/idea-cli-inspector.

ideainspect.groovy

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,14 @@ if (cliOpts.t) {
6262
// timeout
6363
// if (cliOpts.to) ideaTimeout = cliOpts.to.toInteger();
6464
// IDEA home
65-
def scriptExtension = (System.properties['os.name'].toLowerCase().contains('windows')) ? ".bat" : ".sh"
66-
def pathSep = File.separator
67-
def ideaHome = cliOpts.i ?: (System.getenv("IDEA_HOME") ?: "idea")
68-
def ideaPath = new File(ideaHome + pathSep + "bin" + pathSep + "idea" + scriptExtension)
69-
assertPath(ideaPath, "IDEA Installation directory",
70-
"Use a IDEA_HOME environment variable or the `ideahome` property in `.ideainspect` \n" +
71-
"or the `-i` command line option to point me to a valid IntelliJ installation")
65+
File ideaPath = findIdeaExecutable(cliOpts)
7266
// Passed project root Directory or working directory
7367
def rootDir = cliOpts.r ? new File(cliOpts.r) : Paths.get(".").toAbsolutePath().normalize().toFile()
7468
def dotIdeaDir = new File(rootDir, ".idea")
7569
assertPath(dotIdeaDir, "IDEA project directory", "Please set the `rootdir` property to the location of your `.idea` project")
7670
// Inspection Profile
7771
def profileName = cliOpts.p ?: "Project_Default.xml"
78-
def profilePath = new File(dotIdeaDir.path + pathSep + "inspectionProfiles" + pathSep + profileName)
72+
def profilePath = new File(dotIdeaDir.path + File.separator + "inspectionProfiles" + File.separator + profileName)
7973
assertPath(profilePath, "IDEA inspection profile file")
8074

8175
// Prepare result directory
@@ -221,6 +215,28 @@ private OptionAccessor parseCli(configArgs) {
221215
opt
222216
}
223217

218+
private File findIdeaExecutable(OptionAccessor cliOpts) {
219+
def platform = System.properties['os.name'], scriptPath
220+
def ideaHome = cliOpts.i ?: (System.getenv("IDEA_HOME") ?: "idea")
221+
222+
switch (platform) {
223+
case ~/^Windows.*/:
224+
scriptPath = "bin" + File.separator + "idea.bat"
225+
break;
226+
case "Mac OS X":
227+
scriptPath = "Contents/MacOS/idea
228+
break;
229+
default:
230+
scriptPath = "bin/idea.sh"
231+
break;
232+
}
233+
234+
def ideaExecutable = new File(ideaHome + File.separator + scriptPath)
235+
assertPath(ideaExecutable, "IDEA Installation directory",
236+
"Use a IDEA_HOME environment variable or the `ideahome` property in `.ideainspect` \n" +
237+
"or the `-i` command line option to point me to a valid IntelliJ installation")
238+
ideaExecutable
239+
}
224240
225241
private analyzeResult(File resultPath, List<String> acceptedLeves,
226242
List skipResults, List skipIssueFilesRegex) {

0 commit comments

Comments
 (0)