Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intellijinit on Windows #134

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def __exit__(self, tpe, value, traceback):

currently_loading_suite = DynamicVar(None)

def safe_relpath(path, start):
"""Return a relative version of a path if possible. Otherwise just return path"""
try:
return os.path.relpath(path, start)
except ValueError:
return path

# Support for Python 2.6
def check_output(*popenargs, **kwargs):
Expand Down Expand Up @@ -5660,7 +5666,7 @@ def _maven_deploy_dists(dists, versionGetter, repository_id, url, settingsXml, d
for filename in filenames:
emptyJavadoc = False
src = join(dirpath, filename)
dst = os.path.relpath(src, javadocDir)
dst = safe_relpath(src, javadocDir)
arc.write(src, dst)
shutil.rmtree(tmpDir)
if emptyJavadoc:
Expand Down Expand Up @@ -12940,16 +12946,16 @@ def make_library(name, path, source_path):
for library in libraries:
sourcePath = None
if library.isLibrary():
path = os.path.relpath(library.get_path(True), s.dir)
path = safe_relpath(library.get_path(True), s.dir)
if library.sourcePath:
sourcePath = os.path.relpath(library.get_source_path(True), s.dir)
sourcePath = safe_relpath(library.get_source_path(True), s.dir)
elif library.isMavenProject():
path = os.path.relpath(library.get_path(True), s.dir)
sourcePath = os.path.relpath(library.get_source_path(True), s.dir)
path = safe_relpath(library.get_path(True), s.dir)
sourcePath = safe_relpath(library.get_source_path(True), s.dir)
elif library.isJARDistribution():
path = os.path.relpath(library.path, s.dir)
path = safe_relpath(library.path, s.dir)
if library.sourcesPath:
sourcePath = os.path.relpath(library.sourcesPath, s.dir)
sourcePath = safe_relpath(library.sourcesPath, s.dir)
else:
abort('Dependency not supported: {} ({})'.format(library.name, library.__class__.__name__))
make_library(library.name, path, sourcePath)
Expand Down Expand Up @@ -12986,9 +12992,9 @@ def make_library(name, path, source_path):
for apDep in processors:
def processApDep(dep, edge):
if dep.isLibrary() or dep.isJARDistribution():
compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(dep.path, s.dir)})
compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + safe_relpath(dep.path, s.dir)})
elif dep.isProject():
compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(dep.output_dir(), s.dir)})
compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + safe_relpath(dep.output_dir(), s.dir)})
apDep.walk_deps(visit=processApDep)
compilerXml.close('processorPath')
for module in modules:
Expand Down