Skip to content
This repository has been archived by the owner on Jan 14, 2023. It is now read-only.

fix verbosity argument, more verbose output and install to local maven repository #18

Open
wants to merge 10 commits into
base: kinetic
Choose a base branch
from
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# CMake
##############################################################################

cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.0.2)
project(genjava)

##############################################################################
Expand Down
18 changes: 17 additions & 1 deletion cmake/genjava-catkin-api.cmake.em
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,35 @@ macro(generate_rosjava_messages)
message(FATAL_ERROR "generate_rosjava_messages() called with unused arguments: ${ARG_UNPARSED_ARGUMENTS}")
endif()
catkin_rosjava_env_setup()
message(STATUS "ROS_GRADLE_VERBOSE: ${ROS_GRADLE_VERBOSE}")
message(STATUS "ROS_MAVEN_DEPLOYMENT_REPOSITORY: ${ROS_MAVEN_DEPLOYMENT_REPOSITORY}")
message(STATUS "ROS_MAVEN_REPOSITORY: ${ROS_MAVEN_REPOSITORY}")
message(STATUS "GRADLE_USER_HOME: ${GRADLE_USER_HOME}")
set(ROS_GRADLE_VERBOSE $ENV{ROS_GRADLE_VERBOSE})
if(ROS_GRADLE_VERBOSE)
set(verbosity "--verbosity")
else()
set(verbosity "")
endif()
set(avoid_rebuilding "")
#set(avoid_rebuilding "--avoid-rebuilding")
string(REPLACE ";" " " package_list "${ARG_PACKAGES}")

message(STATUS "#### ${PROJECT_NAME}_generate_artifacts ####")
message(STATUS "PROJECT_NAME: ${PROJECT_NAME}")
message(STATUS "CATKIN_ENV: ${CATKIN_ENV}")
message(STATUS "PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
message(STATUS "GENJAVA_MESSAGE_ARTIFACTS_BIN: ${GENJAVA_MESSAGE_ARTIFACTS_BIN}")
message(STATUS "verbosity: ${verbosity}")
message(STATUS "avoid_rebuilding: ${avoid_rebuilding}")
message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "ARG_PACKAGES: ${ARG_PACKAGES}")
message(STATUS "package_list: ${package_list}")
add_custom_target(${PROJECT_NAME}_generate_artifacts
ALL
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENJAVA_MESSAGE_ARTIFACTS_BIN}
${verbosity}
--avoid-rebuilding
${avoid_rebuilding}
-o ${CMAKE_CURRENT_BINARY_DIR}
-p ${ARG_PACKAGES} # this has to be a list argument so it separates each arg (not a single string!)
DEPENDS
Expand Down
28 changes: 15 additions & 13 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<package>
<?xml version="1.0"?>
<?xml-model
href="http://download.ros.org/schema/package_format3.xsd"
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>genjava</name>
<version>0.3.4</version>
<description>
Expand All @@ -16,18 +20,16 @@
<author>Daniel Stonier</author>

<buildtool_depend version_gte="0.5.78">catkin</buildtool_depend>

<build_depend>genmsg</build_depend>
<build_depend>python-catkin-pkg</build_depend>
<build_depend>python-rospkg</build_depend>
<build_depend>rosjava_bootstrap</build_depend>
<build_depend>rosjava_build_tools</build_depend>

<run_depend>genmsg</run_depend>
<run_depend>python-catkin-pkg</run_depend>
<run_depend>python-rospkg</run_depend>
<run_depend>rosjava_bootstrap</run_depend>
<run_depend>rosjava_build_tools</run_depend>
<buildtool_depend condition="$ROS_PYTHON_VERSION == 2">python-setuptools</buildtool_depend>
<buildtool_depend condition="$ROS_PYTHON_VERSION == 3">python3-setuptools</buildtool_depend>

<depend>genmsg</depend>
<depend condition="$ROS_PYTHON_VERSION == 2">python-catkin-pkg</depend>
<depend condition="$ROS_PYTHON_VERSION == 2">python-rospkg</depend>
<depend condition="$ROS_PYTHON_VERSION == 3">python3-catkin-pkg</depend>
<depend condition="$ROS_PYTHON_VERSION == 3">python3-rospkg</depend>
<depend>rosjava_bootstrap</depend>
<depend>rosjava_build_tools</depend>

<export>
<message_generator>java</message_generator>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

from distutils.core import setup
from setuptools import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
Expand Down
8 changes: 4 additions & 4 deletions src/genjava/genjava_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main(argv):
changed and so forth.
'''
args = parse_arguments(argv[1:])
#print("genjava %s/%s" % (args.package, args.message))
print("genjava.main %s" % (args))
if not args.compile:
gradle_project.create(args.package, args.output_dir)
else:
Expand All @@ -88,7 +88,7 @@ def standalone_parse_arguments(argv):
parser = argparse.ArgumentParser(description='Generate artifacts for any/all discoverable message packages.')
parser.add_argument('-p', '--packages', action='store', nargs='*', default=[], help='a list of packages to generate artifacts for')
parser.add_argument('-o', '--output-dir', action='store', default='build', help='output directory for the java code (e.g. build/foo_msgs)')
parser.add_argument('-v', '--verbose', default=False, action='store_true', help='enable verbosity in debugging (false)')
parser.add_argument('-v', '--verbosity', default=False, action='store_true', help='enable verbosity in debugging (false)')
parser.add_argument('-f', '--fakeit', default=False, action='store_true', help='dont build, just list the packages it would build (false)')
parser.add_argument('-a', '--avoid-rebuilding', default=False, action='store_true', help='avoid rebuilding if the working directory is already present (false)')
parsed_arguments = parser.parse_args(argv)
Expand All @@ -102,7 +102,7 @@ def standalone_main(argv):
generate artifacts for.
'''
args = standalone_parse_arguments(argv[1:])
#print("genjava %s/%s/%s" % (args.package, args.output_dir, args.verbose))
print("genjava.standalone_main %s" % (args))

sorted_package_tuples = rosjava_build_tools.catkin.index_message_package_dependencies_from_local_environment(package_name_list=args.packages)

Expand All @@ -111,7 +111,7 @@ def standalone_main(argv):
did_not_rebuild_these_packages = []
if not args.fakeit:
for unused_relative_path, p in sorted_package_tuples:
result = gradle_project.standalone_create_and_build(p.name, args.output_dir, args.verbose, args.avoid_rebuilding)
result = gradle_project.standalone_create_and_build(p.name, args.output_dir, args.verbosity, args.avoid_rebuilding)
if not result:
did_not_rebuild_these_packages.append(p.name)
if did_not_rebuild_these_packages:
Expand Down
7 changes: 4 additions & 3 deletions src/genjava/gradle_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_templates():

def populate_project(project_name, project_version, pkg_directory, gradle_project_dir, msg_dependencies):
author = author_name()
for filename, template in get_templates().iteritems():
for filename, template in get_templates().items():
contents = instantiate_genjava_template(template, project_name, project_version, pkg_directory, author, msg_dependencies)
try:
p = os.path.abspath(os.path.join(gradle_project_dir, filename))
Expand Down Expand Up @@ -152,6 +152,7 @@ def create(msg_pkg_name, output_dir):
raise IOError("could not find %s among message packages. Does the package have a <build_depend> on message_generation in its package.xml?" % msg_pkg_name)

msg_dependencies = create_dependency_string(msg_pkg_name, msg_package_index)
print("msg_dependencies: %s" %msg_dependencies)

create_gradle_wrapper(genjava_gradle_dir)
pkg_directory = os.path.abspath(os.path.dirname(msg_package_index[msg_pkg_name].filename))
Expand All @@ -171,7 +172,7 @@ def build(msg_pkg_name, output_dir, verbosity):
cmd = ['./gradlew']
if not verbosity:
cmd.append('--quiet')
#print("COMMAND........................%s" % cmd)
print("COMMAND build ........................%s" % cmd)
subprocess.call(cmd, stderr=subprocess.STDOUT,)


Expand All @@ -195,6 +196,6 @@ def standalone_create_and_build(msg_pkg_name, output_dir, verbosity, avoid_rebui
cmd = [gradle_wrapper, '-p', working_directory]
if not verbosity:
cmd.append('--quiet')
#print("COMMAND........................%s" % cmd)
print("COMMAND standalone_create_and_build ........................%s" % cmd)
subprocess.call(cmd, stderr=subprocess.STDOUT,)
return True
2 changes: 1 addition & 1 deletion src/genjava/templates/genjava_project/build.gradle.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ task bugfixtask {

jar.dependsOn(bugfixtask)

defaultTasks 'publish'
defaultTasks 'publish', 'install', 'info'