Skip to content
Snippets Groups Projects
Commit 102cd8f0 authored by Daniel Stonier's avatar Daniel Stonier
Browse files

catkin init and create scripts.

parent 597c5f16
Branches
No related tags found
No related merge requests found
Showing
with 1070 additions and 11 deletions
*.class *.class
*.pyc
# Package Files # # Package Files #
*.jar *.jar
......
#!/usr/bin/env python
"""This script creates the skeleton of an android library package"""
##############################################################################
# Imports
##############################################################################
from __future__ import print_function
import argparse
import os
import sys
from rosjava_tools import create_android_package
import rosjava_tools.console as console
##############################################################################
# Main
##############################################################################
if __name__ == "__main__":
try:
sys.exit(create_android_package(is_library=True))
except Exception as e:
console.logerror("%s : %s" % (str(e), type(e)))
sys.exit(1)
#!/usr/bin/env python
"""This script creates the skeleton of an android library package"""
##############################################################################
# Imports
##############################################################################
from __future__ import print_function
import argparse
import os
import sys
from rosjava_tools import create_android_package
import rosjava_tools.console as console
##############################################################################
# Main
##############################################################################
if __name__ == "__main__":
try:
sys.exit(create_android_package(is_library=False))
except Exception as e:
console.logerror("%s : %s" % (str(e), type(e)))
sys.exit(1)
#!/usr/bin/env python
"""This script creates the skeleton of an android repo"""
##############################################################################
# Imports
##############################################################################
from __future__ import print_function
import argparse
import os
import sys
from rosjava_tools import init_android_repo
import rosjava_tools.console as console
##############################################################################
# Main
##############################################################################
if __name__ == "__main__":
try:
sys.exit(init_android_repo())
except Exception as e:
console.logerror("%s : %s" % (str(e), type(e)))
sys.exit(1)
...@@ -6,17 +6,16 @@ from catkin_pkg.python_setup import generate_distutils_setup ...@@ -6,17 +6,16 @@ from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup( d = generate_distutils_setup(
packages=['rosjava_tools'], packages=['rosjava_tools'],
package_dir={'': 'src'}, package_dir={'': 'src'},
#scripts=['scripts/android_generate_project_properties', scripts=['scripts/catkin_init_android_repo',
# 'scripts/catkin_init_android_repo', 'scripts/catkin_create_android_pkg',
# 'scripts/catkin_create_android_pkg', 'scripts/catkin_create_android_library_pkg'
# 'scripts/catkin_create_android_library_pkg' ],
# ], package_data = {'rosjava_tools': [
#package_data = {'rosjava_tools': [ 'gradle/*',
# 'gradle/*', 'gradle/gradle/wrapper/*'
# 'gradle/gradle/wrapper/*' 'templates/android_package/*',
# 'templates/android_package/*', 'templates/init_repo/*',
# 'templates/init_repo/*', ]},
# ]},
requires=['rospy' 'rospkg'] requires=['rospy' 'rospkg']
) )
......
#!/usr/bin/env python
#
# License: Apache 2.0
# https://raw.github.com/ros-java/rosjava_core/hydro-devel/rocon_tools/LICENSE
#
##############################################################################
# Imports
##############################################################################
import console
from init_repo import init_android_repo
from create_package import create_android_package
from utils import which
#!/usr/bin/env python
#
# License: Apache 2.0
# https://raw.github.com/ros-java/rosjava_core/hydro-devel/rocon_tools/LICENSE
#
##############################################################################
# Imports
##############################################################################
import sys
##############################################################################
# Methods
##############################################################################
def console_has_colours(stream):
if not hasattr(stream, "isatty"):
return False
if not stream.isatty():
return False # auto color only on TTYs
try:
import curses
curses.setupterm()
return curses.tigetnum("colors") > 2
except:
# guess false in case of error
return False
has_colours = console_has_colours(sys.stdout)
#reset = "\x1b[0;0m"
reset = "\x1b[0m"
bold = '1'
black, red, green, yellow, blue, magenta, cyan, white = [str(i) for i in range(30, 38)]
bold_black, bold_red, bold_green, bold_yellow, bold_blue, bold_magenta, bold_cyan, bold_white = ['1;' + str(i) for i in range(30, 38)]
colours = [
bold,
black, red, green, yellow, blue, magenta, cyan, white,
bold_black, bold_red, bold_green, bold_yellow, bold_blue, bold_magenta, bold_cyan, bold_white
]
def pretty_print(msg, colour=white):
if has_colours:
seq = "\x1b[%sm" % (colour) + msg + reset
sys.stdout.write(seq)
else:
sys.stdout.write(msg)
def pretty_println(msg, colour=white):
if has_colours:
seq = "\x1b[%sm" % (colour) + msg + reset
sys.stdout.write(seq)
sys.stdout.write("\n")
else:
sys.stdout.write(msg)
##############################################################################
# Console
##############################################################################
def debug(msg):
pretty_print("%s\n" % msg, green)
def warning(msg):
pretty_print("%s\n" % msg, yellow)
def error(msg):
pretty_print("%s\n" % msg, red)
def logdebug(message):
pretty_print("[debug] " + message + "\n", green)
def logwarn(message):
pretty_print("[warning] " + message + "\n", yellow)
def logerror(message):
pretty_print("[error] " + message + "\n", red)
def logfatal(message):
pretty_print("[error] " + message + "\n", bold_red)
##############################################################################
# Main
##############################################################################
if __name__ == '__main__':
for colour in colours:
pretty_print("dude\n", colour)
logdebug("info message")
logwarn("warning message")
logerror("error message")
logfatal("fatal message")
pretty_print("red\n", red)
print("some normal text")
#!/usr/bin/env python
#
# License: Apache 2.0
# https://raw.github.com/ros-java/rosjava_core/hydro-devel/rocon_tools/LICENSE
#
##############################################################################
# Imports
##############################################################################
from __future__ import print_function
import os
import sys
import argparse
import subprocess
import shutil
# local imports
import utils
import console
import catkin_pkg
from catkin_pkg.package_templates import create_package_xml, PackageTemplate
##############################################################################
# Methods
##############################################################################
def parse_arguments():
argv = sys.argv[1:]
parser = argparse.ArgumentParser(
description='Creates a new android package based on catkin and gradle. \n')
parser.add_argument('name',
nargs=1,
help='The name for the package')
parser.add_argument('dependencies',
nargs='*',
help='Android library dependencies')
parser.add_argument('-l', '--license',
action='append',
default=["Apache 2.0"],
help='Name for License, (e.g. BSD, MIT, GPLv3...)[BSD]')
parser.add_argument('-a', '--author',
action='append',
default=[utils.author_name()],
help='A single author, may be used multiple times')
parser.add_argument('-m', '--maintainer',
action='append',
help='A single maintainer, may be used multiple times')
parser.add_argument('-V', '--pkg_version',
action='store',
default="0.1.0",
help='Initial Package version [0.1.0]')
parser.add_argument('-D', '--description',
action='store',
help='Description')
parser.add_argument('-s', '--sdk-version',
action='store',
default='17',
help='Android sdk version [17]')
parser.add_argument('-p', '--android-package-name',
action='store',
default='com.github.rosjava.android.pkg_name',
help='Android package name (e.g. com.github.rosjava.android.pkg_name)')
args = parser.parse_args(argv)
if args.android_package_name == "com.github.rosjava.android.pkg_name":
args.android_package_name = "com.github.rosjava.android.%s" % args.name[0].lower()
if "rosjava_tools" not in args.dependencies:
args.dependencies.append('rosjava_tools')
return args
def create_android_project(package_name, sdk_version, java_package_name, is_library):
path = os.path.join(os.getcwd(), package_name.lower())
console.pretty_println("\nCreating android project ", console.bold)
console.pretty_print(" Name : ", console.cyan)
console.pretty_println("%s" % package_name, console.yellow)
console.pretty_print(" Sdk Ver : ", console.cyan)
console.pretty_println("%s" % sdk_version, console.yellow)
console.pretty_print(" Java Name : ", console.cyan)
console.pretty_println("%s" % java_package_name, console.yellow)
if is_library:
console.pretty_print(" Library : ", console.cyan)
console.pretty_println("yes\n", console.yellow)
cmd = ['android', 'create', 'lib-project', '-n', package_name, '-p', path, '-k', java_package_name, '-t', 'android-' + sdk_version, ]
else:
activity_name = utils.camel_case(package_name)
console.pretty_print(" Activity : ", console.cyan)
console.pretty_println("%s\n" % activity_name, console.yellow)
cmd = ['android', 'create', 'project', '-n', package_name, '-p', path, '-k', java_package_name, '-t', 'android-' + sdk_version, '-a', activity_name]
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
raise subprocess.CalledProcessError("failed to create android project.")
# This is in the old form, let's shovel the shit around to the new form
utils.mkdir_p(os.path.join(path, 'src', 'main', 'java'))
os.remove(os.path.join(path, 'local.properties'))
os.remove(os.path.join(path, 'project.properties'))
os.remove(os.path.join(path, 'ant.properties'))
os.remove(os.path.join(path, 'proguard-project.txt'))
os.remove(os.path.join(path, 'build.xml'))
os.rmdir(os.path.join(path, 'bin'))
os.rmdir(os.path.join(path, 'libs'))
shutil.move(os.path.join(path, 'AndroidManifest.xml'), os.path.join(path, 'src', 'main'))
shutil.move(os.path.join(path, 'res'), os.path.join(path, 'src', 'main'))
if not is_library:
shutil.move(os.path.join(path, 'src', java_package_name.split('.')[0]), os.path.join(path, 'src', 'main', 'java'))
##############################################################################
# Methods acting on classes
##############################################################################
# This inserts the labelled variables into the template wherever the corresponding
# %package, %brief, %description and %depends is found.
def instantiate_template(template, package_name, author, plugin_name, sdk_version):
return template % locals()
def create_catkin_package_files(args, is_library, sdk_version):
'''
This is almost a direct copy from catkin_create_pkg.
'''
plugin_name = "android-library" if is_library else "android"
try:
package_name = args.name[0].lower()
parent_path = os.getcwd()
target_path = utils.validate_path(os.path.join(parent_path, package_name))
build_depends = []
if 'rosjava_tools' not in args.dependencies:
build_depends.append('rosjava_tools')
for depend_name in args.dependencies:
build_depends.append(catkin_pkg.package.Dependency(depend_name))
package_template = PackageTemplate._create_package_template(
package_name=package_name,
description=args.description,
licenses=args.license or [],
maintainer_names=args.maintainer,
author_names=args.author,
version=args.pkg_version,
catkin_deps=[],
system_deps=[],
boost_comps=None)
package_template.exports = []
package_template.build_depends = build_depends
package_xml = create_package_xml(package_template=package_template, rosdistro='groovy')
package_path = os.path.abspath(os.path.join(os.getcwd(), package_name))
filename = os.path.join(package_path, 'package.xml')
console.pretty_println("\nCreating catkin/gradle files", console.bold)
try:
f = open(filename, 'w')
f.write(package_xml)
console.pretty_print(' File: ', console.cyan)
console.pretty_println('package.xml', console.yellow)
finally:
f.close()
# Other files
for template_name in ['build.gradle', 'CMakeLists.txt']:
filename = os.path.join(package_path, template_name)
template = read_template_file(template_name)
contents = instantiate_template(template, package_name, args.author[0], plugin_name, sdk_version)
try:
f = open(filename, 'w')
f.write(contents)
console.pretty_print(' File: ', console.cyan)
console.pretty_println(template_name, console.yellow)
finally:
f.close()
except Exception:
raise
def add_to_root_gradle_settings(name):
'''
Adds project name to the root level settings.gradle file.
'''
for rel_path in ['.', '..']:
settings_gradle_path = os.path.join(os.getcwd(), rel_path, 'settings.gradle')
if os.path.isfile(settings_gradle_path):
break
else:
settings_gradle_path = None
if settings_gradle_path is None:
console.pretty_println("\nCouldn't find the root level settings.gradle file - not adding to the superproject.")
return
with open(settings_gradle_path, 'a') as settings_gradle:
console.pretty_println("\nIncluding '%s' in the root gradle project configuration (settings.gradle).\n" % name, console.bold)
settings_gradle.write("include '%s'\n" % name)
def create_android_package(is_library=False):
args = parse_arguments()
create_android_project(args.name[0], args.sdk_version, args.android_package_name, is_library)
create_catkin_package_files(args, is_library, args.sdk_version)
add_to_root_gradle_settings(args.name[0])
##############################################################################
# Borrowed from catkin_pkg.package_templates
##############################################################################
from catkin_pkg.package_templates import _create_depend_tag, \
PACKAGE_MANIFEST_FILENAME, CatkinTemplate
def read_template_file(filename):
template_dir = os.path.join(os.path.dirname(__file__), 'templates', 'android_package')
template = os.path.join(template_dir, '%s.in' % filename)
if not os.path.isfile(template):
raise IOError(
"Could not read template [%s]" % template
)
with open(template, 'r') as fhand:
template_contents = fhand.read()
return template_contents
def create_package_xml(package_template, rosdistro):
"""
:param package_template: contains the required information
:returns: file contents as string
"""
package_xml_template = read_template_file(PACKAGE_MANIFEST_FILENAME)
ctemp = CatkinTemplate(package_xml_template)
temp_dict = {}
for key in package_template.__slots__:
temp_dict[key] = getattr(package_template, key)
if package_template.version_abi:
temp_dict['version_abi'] = ' abi="%s"' % package_template.version_abi
else:
temp_dict['version_abi'] = ''
if not package_template.description:
temp_dict['description'] = 'The %s package ...' % package_template.name
licenses = []
for plicense in package_template.licenses:
licenses.append(' <license>%s</license>\n' % plicense)
temp_dict['licenses'] = ''.join(licenses)
def get_person_tag(tagname, person):
email_string = (
"" if person.email is None else 'email="%s"' % person.email
)
return ' <%s %s>%s</%s>\n' % (tagname, email_string,
person.name, tagname)
maintainers = []
for maintainer in package_template.maintainers:
maintainers.append(get_person_tag('maintainer', maintainer))
temp_dict['maintainers'] = ''.join(maintainers)
urls = []
for url in package_template.urls:
type_string = ("" if url.type is None
else 'type="%s"' % url.type)
urls.append(' <url %s >%s</url>\n' % (type_string, url.url))
temp_dict['urls'] = ''.join(urls)
authors = []
for author in package_template.authors:
authors.append(get_person_tag('author', author))
temp_dict['authors'] = ''.join(authors)
dependencies = []
dep_map = {
'build_depend': package_template.build_depends,
'buildtool_depend': package_template.buildtool_depends,
'run_depend': package_template.run_depends,
'test_depend': package_template.test_depends,
'conflict': package_template.conflicts,
'replace': package_template.replaces
}
for dep_type in ['buildtool_depend', 'build_depend', 'run_depend',
'test_depend', 'conflict', 'replace']:
for dep in sorted(dep_map[dep_type], key=lambda x: x.name):
if 'depend' in dep_type:
dep_tag = _create_depend_tag(
dep_type,
dep.name,
dep.version_eq,
dep.version_lt,
dep.version_lte,
dep.version_gt,
dep.version_gte
)
dependencies.append(dep_tag)
else:
dependencies.append(_create_depend_tag(dep_type,
dep.name))
temp_dict['dependencies'] = ''.join(dependencies)
exports = []
if package_template.exports is not None:
for export in package_template.exports:
if export.content is not None:
print('WARNING: Create package does not know how to '
'serialize exports with content: '
'%s, %s, ' % (export.tagname, export.attributes) +
'%s' % (export.content),
file=sys.stderr)
else:
attribs = [' %s="%s"' % (k, v) for (k, v) in export.attributes.items()]
line = ' <%s%s/>\n' % (export.tagname, ''.join(attribs))
exports.append(line)
temp_dict['exports'] = ''.join(exports)
temp_dict['components'] = package_template.catkin_deps
return ctemp.substitute(temp_dict)
\ No newline at end of file
This is not installed, but it gets used to generate the gradle wrapper for a project.
It is currently the gradle wrapper supporting gradle 1.6.
\ No newline at end of file
#Sun May 26 11:09:41 KST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
#!/usr/bin/env python
#
# License: Apache 2.0
# https://raw.github.com/ros-java/rosjava_core/hydro-devel/rocon_tools/LICENSE
#
##############################################################################
# Imports
##############################################################################
import os
import sys
import argparse
import subprocess
# local imports
import utils
import console
##############################################################################
# Methods
##############################################################################
def parse_arguments():
argv = sys.argv[1:]
parser = argparse.ArgumentParser(
description='Creates a new android repository based on catkin and gradle. \n\nNote that the path you provide will become the maven group for your repo.\n')
parser.add_argument('path', nargs='?', default=os.getcwd(), help='path to the repository you wish to create (must not exist beforehand).')
args = parser.parse_args(argv)
return args
# Finds and reads one of the templates.
def read_template(tmplf):
f = open(tmplf, 'r')
try:
t = f.read()
finally:
f.close()
return t
# This inserts the labelled variables into the template wherever the corresponding
# %package, %brief, %description and %depends is found.
def instantiate_template(template, repo_name, author):
return template % locals()
def get_templates():
template_dir = os.path.join(os.path.dirname(__file__), 'templates', 'init_repo')
templates = {}
templates['build.gradle'] = read_template(os.path.join(template_dir, 'build.gradle.in'))
templates['settings.gradle'] = read_template(os.path.join(template_dir, 'settings.gradle'))
return templates
def populate_repo(repo_path):
author = utils.author_name()
repo_name = os.path.basename(repo_path)
templates = get_templates()
for filename, template in templates.iteritems():
contents = instantiate_template(template, repo_name, author)
try:
p = os.path.abspath(os.path.join(repo_path, filename))
f = open(p, 'w')
f.write(contents)
console.pretty_print("Created repo file: ", console.cyan)
console.pretty_println("%s" % p, console.yellow)
finally:
f.close()
def create_gradle_wrapper(repo_path):
gradle_binary = os.path.join(os.path.dirname(__file__), 'gradle', 'gradlew')
cmd = [gradle_binary, '-p', repo_path, 'wrapper']
console.pretty_print("Creating gradle wrapper: ", console.cyan)
console.pretty_println("%s" % ' '.join(cmd), console.yellow)
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
raise subprocess.CalledProcessError("failed to create the gradle wrapper.")
##############################################################################
# Methods acting on classes
##############################################################################
def init_android_repo():
args = parse_arguments()
try:
repo_path = utils.validate_path(args.path)
populate_repo(repo_path)
create_gradle_wrapper(repo_path)
except Exception:
raise
##############################################################################
# CMake
##############################################################################
cmake_minimum_required(VERSION 2.8.3)
project(%(package_name)s)
##############################################################################
# Catkin
##############################################################################
find_package(catkin REQUIRED rosjava_tools)
catkin_android_setup()
catkin_package()
/*
* Copyright (C) 2013 %(author)s.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/*
Examples of
1) dependencies from another project in this gradle stack.
2) dependency from a maven repository.
*/
/*
dependencies {
compile project(':android_apps_core_components')
compile 'ros.android_core:android_gingerbread_mr1:0.0.0-SNAPSHOT'
}
*/
apply plugin: '%(plugin_name)s'
android {
compileSdkVersion %(sdk_version)s
buildToolsVersion androidBuildToolsVersion
}
<?xml version="1.0"?>
<package>
<name>@name</name>
<version@version_abi>@version</version>
<description>@description</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- <maintainer email="jane.doe@@example.com">Jane Doe</maintainer> -->
@maintainers
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
@licenses
<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<url type="website">http://ros.org/wiki/@name</url>
<!-- <url type="repository">https://github.com/ros-java/android_honeycomb</url> -->
<!-- <url type="bugtracker">https://github.com/ros-java/android_honeycomb/issues</url> -->
@urls
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Example: -->
<!-- <author email="jane.doe@@example.com">Jane Doe</author> -->
@authors
<!-- The rosjava_tool depends is for cmake injection of catkin_android_setup -->
<!-- Other build_depend tags are used to specify android library dependencies -->
<!-- e.g. android_gingerbread, android_honeycomb -->
<!-- No run_depend tags are necessary since we download to the device -->
@dependencies
</package>
/*
* Copyright (C) 2013 %(author)s
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
task wrapper(type: Wrapper) {
gradleVersion = '1.6'
}
allprojects {
group 'ros.%(repo_name)s'
version = '0.1.0'
}
ext.androidBuildToolsVersion = "17"
subprojects {
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.1'
}
}
apply plugin: 'maven'
repositories {
mavenLocal()
maven {
url 'http://robotbrains.hideho.org/nexus/content/groups/ros-public'
}
}
configurations.add('compile') {
exclude group: 'junit'
exclude group: 'xml-apis'
}
/*
EXPERIMENTAL: Trick to get local maven installs until the plugin supports an
install step for aar's (coming soon).
*/
uploadArchives {
repositories {
mavenDeployer {
repository url: 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
}
}
}
task install() << {
description = 'installs .aar files to the local maven repository.'
}
/* Get the debug versions of the aar's as well. */
afterEvaluate { Project project ->
if (plugins.findPlugin('android-library')) {
task doDebugArchives() << {
project.artifacts.add("default", bundleDebug)
}
doDebugArchives.dependsOn('bundleDebug')
uploadArchives.dependsOn('doDebugArchives')
install.dependsOn('uploadArchives')
}
}
}
/*
* Copyright (C) 2013 %(author)s
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/* Uncomment these and add your own packages to be gradled
include 'my_android_project'
include 'my_android_library_project'
*/
#!/usr/bin/env python
#
# License: Apache 2.0
# https://raw.github.com/ros-java/rosjava_core/hydro-devel/rosjava_tools/LICENSE
#
##############################################################################
# Imports
##############################################################################
import os
import errno
import pwd
##############################################################################
# Methods
##############################################################################
def which(program):
'''
Looks for program in the environment.
@param program : string name of the program (e.g. 'ls')
@type str
@return absolute pathname of the program or None
@rtype str or None
'''
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, unused_fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def camel_case(word):
return ''.join(x.capitalize() or '_' for x in word.split('_'))
def author_name():
"""
Utility to compute logged in user name
:returns: name of current user, ``str``
"""
import getpass
name = getpass.getuser()
try:
login = name
name = pwd.getpwnam(login)[4]
name = ''.join(name.split(',')) # strip commas
# in case pwnam is not set
if not name:
name = login
except:
#pwd failed
pass
if type(name) == str:
name = name.decode('utf-8')
return name
def mkdir_p(path):
'''
Enables mkdir -p functionality (until python 3.2 is able to use
the mode argument to do the same).
'''
try:
os.makedirs(path)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise os.mkdir(os.path.join(path, 'src', 'main', 'java'))
def validate_path(path):
'''
Validates that there isn't a gradle project in the specified path.
We use this when creating an android repo/package.
@param path : path where you wish to create the repository/package.
@type str
@raise RuntimeError
@return path : validated (exists) absolute pathname
'''
if not os.path.isabs(path):
absolute_path = os.path.join(os.getcwd(), path)
else:
absolute_path = path
if not os.path.exists(absolute_path):
os.mkdir(absolute_path)
else:
if os.path.isfile(os.path.join(path, 'build.gradle')):
raise ValueError("Error: a gradle project already resides in this location [%s]" % absolute_path)
return absolute_path
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment