Skip to content
Snippets Groups Projects
Commit f7c210b1 authored by Antoine Pietri's avatar Antoine Pietri
Browse files

server: proper JAR deployment method

parent 0b203090
No related branches found
No related tags found
No related merge requests found
POM_PATH=java/server/pom.xml
java:
mvn -f $(POM_PATH) compile assembly:single
.PHONY: java
......@@ -8,6 +8,7 @@ from setuptools import setup, find_packages
from os import path
from io import open
from glob import glob
here = path.abspath(path.dirname(__file__))
......@@ -35,6 +36,8 @@ def parse_requirements(name=None):
return requirements
JAR_PATHS = list(glob('java/server/target/swh-graph-*.jar'))
setup(
name='swh.graph',
description='Software Heritage graph service',
......@@ -50,6 +53,7 @@ setup(
extras_require={'testing': parse_requirements('test')},
vcversioner={},
include_package_data=True,
data_files=[('share/swh-graph', JAR_PATHS)],
entry_points='''
[console_scripts]
swh-graph=swh.graph.cli:main
......
# Copyright (C) 2019 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import asyncio
import contextlib
import json
import os
import pathlib
import struct
import sys
import tempfile
......@@ -15,10 +21,18 @@ BIN_FMT = '>q' # 64 bit integer, big endian
NODE2PID_EXT = 'node2pid.bin'
PID2NODE_EXT = 'pid2node.bin'
JAR_PATH = os.path.join(
os.path.dirname(__file__), '../../..',
'java/server/target/swh-graph-0.0.2-jar-with-dependencies.jar'
)
def find_graph_jar():
swh_graph_root = pathlib.Path(__file__).parents[3]
try_paths = [
swh_graph_root / 'java/server/target/',
pathlib.Path(sys.prefix) / 'share/swh-graph/',
]
for path in try_paths:
glob = list(path.glob('swh-graph-*.jar'))
if glob:
return str(glob[0])
raise RuntimeError("swh-graph-*.jar not found. Have you run `make java`?")
class Backend:
......@@ -30,7 +44,7 @@ class Backend:
def __enter__(self):
self.gateway = JavaGateway.launch_gateway(
java_path=None,
classpath=JAR_PATH, # noqa
classpath=find_graph_jar(),
die_on_exit=True,
redirect_stdout=sys.stdout,
redirect_stderr=sys.stderr,
......
......@@ -5,7 +5,9 @@ envlist=flake8,py3,mypy
deps =
.[testing]
pytest-cov
whitelist_externals = mvn
commands =
mvn -f java/server/pom.xml compile assembly:single
pytest --cov=swh --cov-branch {posargs}
[testenv:flake8]
......@@ -17,6 +19,7 @@ commands =
[testenv:mypy]
skip_install = true
ignore_missing_imports = true
deps =
.[testing]
mypy
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment