diff --git a/jgo/jgo.py b/jgo/jgo.py index 5d71243..0b1b78f 100644 --- a/jgo/jgo.py +++ b/jgo/jgo.py @@ -231,7 +231,7 @@ def find_endpoint(argv, shortcuts={}): pattern = re.compile('.*https?://.*') indices = [] for index, arg in enumerate(argv): - if arg in shortcuts or (Endpoint.is_endpoint(arg) and not pattern.match(arg)): + if any(a in shortcuts for a in arg.split('+')) or (Endpoint.is_endpoint(arg) and not pattern.match(arg)): indices.append(index) return -1 if len(indices) == 0 else indices[-1] @@ -367,6 +367,7 @@ def split_endpoint_string(endpoint_string): return endpoint_strings def endpoints_from_strings(endpoint_strings, shortcuts={}): + _logger.debug('Creating endpoints from strings %s with shortcuts %s', endpoint_strings, shortcuts) return [Endpoint.parse_endpoint(expand_coordinate(ep, shortcuts=shortcuts)) for ep in endpoint_strings] def coordinates_from_endpoints(endpoints): diff --git a/tests/test_shortcut_expansion.py b/tests/test_shortcut_expansion.py new file mode 100644 index 0000000..9ce95ca --- /dev/null +++ b/tests/test_shortcut_expansion.py @@ -0,0 +1,29 @@ +import jgo +import pathlib +import tempfile +import unittest + +import logging +_logger = logging.getLogger(__name__) + +class ExpansionTest(unittest.TestCase): + + def test_groovy_issue_46(self): + shortcuts = {'groovy': 'org.codehaus.groovy:groovy-groovysh:org.codehaus.groovy.tools.shell.Main+commons-cli:commons-cli:1.3.1'} + + tmp_dir = tempfile.mkdtemp(prefix='jgo-test-cache-dir') + m2_repo = pathlib.Path.home() / '.m2' / 'repository' + + primary_endpoint, workspace = jgo.resolve_dependencies( + 'groovy', + cache_dir = tmp_dir, + m2_repo = m2_repo, + update_cache = True, + shortcuts = shortcuts, + verbose = 1) + _logger.debug('Got primary_endpoint %s and workspace %s', primary_endpoint, workspace) + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + unittest.main() \ No newline at end of file