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

Commit 48c4955

Browse files
committed
provide a limited scope path for unofficial message generation to avoid picking up old versions.
1 parent c443411 commit 48c4955

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

gradle_plugins/src/main/groovy/org/ros/gradle_plugins/CatkinPlugin.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ class CatkinPackage {
108108
def name
109109
def version
110110
def dependencies
111+
def directory
111112

112113
def CatkinPackage(File packageXmlFilename) {
113114
def packageXml = new XmlParser().parse(packageXmlFilename)
115+
directory = packageXmlFilename.parent
114116
name = packageXml.name.text()
115117
version = packageXml.version.text()
116118
dependencies = []
@@ -181,7 +183,7 @@ class CatkinPackage {
181183
def generateSourcesTask = p.tasks.create("generateSources", JavaExec)
182184
generateSourcesTask.description = "Generate sources for " + name
183185
generateSourcesTask.outputs.dir(p.file(generatedSourcesDir))
184-
generateSourcesTask.args = new ArrayList<String>([generatedSourcesDir, name])
186+
generateSourcesTask.args = new ArrayList<String>([generatedSourcesDir, '--package-path=' + directory, name])
185187
generateSourcesTask.classpath = p.configurations.runtime
186188
generateSourcesTask.main = 'org.ros.internal.message.GenerateInterfaces'
187189
p.tasks.compileJava.source generateSourcesTask.outputs.files

message_generation/src/main/java/org/ros/internal/message/GenerateInterfaces.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.io.IOException;
3434
import java.util.Collection;
3535
import java.util.List;
36+
import java.util.ListIterator;
3637

3738
/**
3839
* @author damonkohler@google.com (Damon Kohler)
@@ -69,7 +70,6 @@ private void writeTopicInterfaces(File outputDirectory, Collection<String> packa
6970
packages = topicDefinitionFileProvider.getPackages();
7071
}
7172
for (String pkg : packages) {
72-
System.out.println("Package: " + pkg);
7373
Collection<MessageIdentifier> messageIdentifiers =
7474
topicDefinitionFileProvider.getMessageIdentifiersByPackage(pkg);
7575
if (messageIdentifiers != null) {
@@ -159,6 +159,15 @@ public static void main(String[] args) {
159159
arguments.add(".");
160160
}
161161
String rosPackagePath = System.getenv(ROS_PACKAGE_PATH);
162+
// Overwrite with a supplied package path if specified (--package-path=)
163+
for (ListIterator<String> iter = arguments.listIterator(); iter.hasNext(); ) {
164+
String arg = iter.next();
165+
if (arg.contains("--package-path=")) {
166+
rosPackagePath = arg.replace("--package-path=", "");
167+
iter.remove();
168+
break;
169+
}
170+
}
162171
Collection<File> packagePath = Lists.newArrayList();
163172
for (String path : rosPackagePath.split(File.pathSeparator)) {
164173
File packageDirectory = new File(path);

0 commit comments

Comments
 (0)