-
Notifications
You must be signed in to change notification settings - Fork 0
/
AspectJWeaver.py
51 lines (45 loc) · 1.63 KB
/
AspectJWeaver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
from pathlib import Path
import platform
import subprocess
class AspectJWeaver:
def __init__(self, srcdir, codedir, dstdir):
self.srcdir = os.path.abspath(srcdir) # Location os aspect files
self.codedir = os.path.abspath(codedir) # Code to weave aspect files in
self.dstdir = os.path.abspath(dstdir) # Output directory
self.__source = "1.9"
self.__target = "1.9"
self.__classpath = []
self.classpath = sorted(list(map(str, Path(os.environ.get('ANDROID_HOME')).glob('platforms/*'))), reverse=True)[0]
self.__sourcefiles = list(map(str, Path(self.srcdir).glob('**/*.java')))
self.__options = ['-Xlint:ignore']
@property
def classpath(self):
return self.__classpath
@classpath.setter
def classpath(self, path):
self.__classpath = self.__classpath + list(map(str, Path(os.path.abspath(path)).glob('**/*.jar')))
@property
def java_executable(self):
ext = ''
if (platform.system() == 'Windows'):
ext = '.exe'
return os.path.join(os.environ.get('JAVA_HOME'), 'bin', 'java{0}'.format(ext))
def exec(self):
command = [
self.java_executable,
'-classpath',
';'.join(self.classpath),
'org.aspectj.tools.ajc.Main',
'-sourceroots',
self.srcdir,
'-inpath',
self.codedir,
'-d',
self.dstdir,
'-source',
self.__source,
'-target',
self.__target,
] + self.__options
ret = subprocess.check_call(command, stdout=subprocess.DEVNULL)