[ONOS-5785] Refactor code into new folder structure
Change-Id: I115d5af1cd7bfbde71a3092973fe160ec1d9bae5
diff --git a/compiler/plugin/buck/pom.xml b/compiler/plugin/buck/pom.xml
new file mode 100644
index 0000000..958a92d
--- /dev/null
+++ b/compiler/plugin/buck/pom.xml
@@ -0,0 +1,68 @@
+<!--
+ ~ Copyright 2016-present Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-yang-compiler-plugin</artifactId>
+ <version>1.12-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-yang-compiler-buck-plugin</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>buck-api</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-yang-compiler-tool</artifactId>
+ <version>1.12-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.4.3</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <artifactSet>
+ <excludes>
+ <exclude>com.google.guava:guava</exclude>
+ </excludes>
+ </artifactSet>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangGenerator.java b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangGenerator.java
new file mode 100644
index 0000000..ea69169
--- /dev/null
+++ b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangGenerator.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.
+ */
+
+package org.onosproject.yang.compiler.plugin.buck;
+
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.utils.DataModelUtils;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.base.tool.CallablePlugin;
+import org.onosproject.yang.compiler.base.tool.YangToolManager;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.util.stream.Collectors.toList;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
+import static org.onosproject.yang.compiler.utils.UtilConstants.YANG_RESOURCES;
+
+/**
+ * Generates Java sources from a Yang model.
+ */
+public class YangGenerator implements CallablePlugin {
+
+ private final List<File> models;
+ private final List<String> depJar;
+ private final String DEFAULT_JAR_RES_PATH = SLASH + YANG_RESOURCES + SLASH;
+ private String outputDirectory;
+
+ YangGenerator(List<File> models, String outputDirectory, List<String> depJar) {
+ this.models = models;
+ this.depJar = depJar;
+ this.outputDirectory = outputDirectory + SLASH;
+ }
+
+ public void execute() throws YangParsingException {
+ List<String> files = getListOfFile();
+ synchronized (files) {
+ try {
+ YangPluginConfig config = new YangPluginConfig();
+ config.setCodeGenDir(outputDirectory);
+ config.resourceGenDir(outputDirectory + DEFAULT_JAR_RES_PATH);
+ //for inter-jar linking.
+ List<YangNode> dependentSchema = new ArrayList<>();
+ for (String jar : depJar) {
+ dependentSchema.addAll(DataModelUtils.parseJarFile(jar, outputDirectory));
+ }
+ //intra jar file linking.
+ YangToolManager manager = new YangToolManager();
+ manager.compileYangFiles(manager.createYangFileInfoSet(files),
+ dependentSchema, config, this);
+ } catch (Exception e) {
+ throw new YangParsingException(e);
+ }
+ }
+ }
+
+ private List<String> getListOfFile() {
+ List<String> files = new ArrayList<>();
+ if (models != null) {
+ synchronized (models) {
+ files.addAll(models.stream().map(File::toString)
+ .collect(toList()));
+ }
+ }
+ return files;
+ }
+
+ @Override
+ public void addGeneratedCodeToBundle() {
+ //TODO: add functionality.
+ }
+
+ @Override
+ public void addCompiledSchemaToBundle() throws IOException {
+ //TODO: add functionality.
+ }
+
+ @Override
+ public void addYangFilesToBundle() throws IOException {
+ //TODO: add functionality.
+ }
+}
diff --git a/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangLibrary.java b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangLibrary.java
new file mode 100644
index 0000000..0eed357
--- /dev/null
+++ b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangLibrary.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.
+ */
+
+package org.onosproject.yang.compiler.plugin.buck;
+
+import com.facebook.buck.jvm.java.JarDirectoryStep;
+import com.facebook.buck.model.BuildTargets;
+import com.facebook.buck.rules.AbstractBuildRule;
+import com.facebook.buck.rules.AddToRuleKey;
+import com.facebook.buck.rules.BuildContext;
+import com.facebook.buck.rules.BuildRuleParams;
+import com.facebook.buck.rules.BuildableContext;
+import com.facebook.buck.rules.SourcePath;
+import com.facebook.buck.rules.SourcePathResolver;
+import com.facebook.buck.step.Step;
+import com.facebook.buck.step.fs.MakeCleanDirectoryStep;
+import com.facebook.buck.step.fs.MkdirStep;
+import com.facebook.buck.step.fs.RmStep;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSortedSet;
+
+import javax.annotation.Nullable;
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
+import static org.onosproject.yang.compiler.utils.UtilConstants.YANG;
+
+/**
+ * Buck rule to define a library built form a Yang model.
+ */
+public class YangLibrary extends AbstractBuildRule {
+
+ @AddToRuleKey
+ private final ImmutableSortedSet<SourcePath> srcs;
+ private final BuildRuleParams params;
+
+ private final Path genSrcsDirectory;
+ private final Path outputDirectory;
+ private final Path output;
+
+ public YangLibrary(
+ BuildRuleParams params,
+ SourcePathResolver resolver,
+ ImmutableSortedSet<SourcePath> srcs) {
+ super(params, resolver);
+ this.srcs = srcs;
+ this.params = params;
+ genSrcsDirectory = BuildTargets.getGenPath(getProjectFilesystem(),
+ params.getBuildTarget(),
+ "%s__yang-gen");
+ outputDirectory = BuildTargets.getGenPath(getProjectFilesystem(),
+ params.getBuildTarget(),
+ "%s__yang-output");
+ output = Paths.get(String.format("%s/%s-sources.jar",
+ outputDirectory,
+ params.getBuildTarget().getShortNameAndFlavorPostfix()));
+ }
+
+ @Override
+ public ImmutableList<Step> getBuildSteps(BuildContext buildContext, BuildableContext buildableContext) {
+ ImmutableList.Builder<Step> steps = ImmutableList.builder();
+
+ // Delete the old output for this rule, if it exists.
+ steps.add(
+ new RmStep(
+ getProjectFilesystem(),
+ getPathToOutput(),
+ /* shouldForceDeletion */ true,
+ /* shouldRecurse */ true));
+
+ // Make sure that the directory to contain the output file exists. Rules get output to a
+ // directory named after the base path, so we don't want to nuke the entire directory.
+ steps.add(new MkdirStep(getProjectFilesystem(), outputDirectory));
+
+ steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), genSrcsDirectory));
+
+ List<Path> sourcePaths = srcs.stream()
+ .map(s -> getResolver().getRelativePath(s))
+ .collect(Collectors.toList());
+
+ steps.add(new YangStep(getProjectFilesystem(), sourcePaths, genSrcsDirectory,
+ params.getDeps()));
+
+ steps.add(new JarDirectoryStep(
+ getProjectFilesystem(),
+ output,
+ ImmutableSortedSet.of(genSrcsDirectory),
+ null,
+ null));
+
+ return steps.build();
+ }
+
+ @Nullable
+ @Override
+ public Path getPathToOutput() {
+ return output;
+ }
+
+
+ /**
+ * Returns generated sources directory.
+ *
+ * @return generated sources directory
+ */
+ public Path getGenSrcsDirectory() {
+ File dir = new File(genSrcsDirectory.toString() + SLASH + YANG);
+ dir.mkdirs();
+ return genSrcsDirectory;
+ }
+
+}
diff --git a/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangLibraryDescription.java b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangLibraryDescription.java
new file mode 100644
index 0000000..dc088dd
--- /dev/null
+++ b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangLibraryDescription.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.
+ */
+
+package org.onosproject.yang.compiler.plugin.buck;
+
+import com.facebook.buck.cli.BuckConfig;
+import com.facebook.buck.jvm.java.CalculateAbi;
+import com.facebook.buck.jvm.java.DefaultJavaLibrary;
+import com.facebook.buck.jvm.java.JavaBuckConfig;
+import com.facebook.buck.jvm.java.JavaOptions;
+import com.facebook.buck.jvm.java.JavacOptions;
+import com.facebook.buck.jvm.java.JavacOptionsAmender;
+import com.facebook.buck.jvm.java.JavacOptionsFactory;
+import com.facebook.buck.jvm.java.JavacToJarStepFactory;
+import com.facebook.buck.jvm.java.JvmLibraryArg;
+import com.facebook.buck.model.BuildTarget;
+import com.facebook.buck.model.BuildTargets;
+import com.facebook.buck.model.Flavor;
+import com.facebook.buck.model.Flavored;
+import com.facebook.buck.model.ImmutableFlavor;
+import com.facebook.buck.model.UnflavoredBuildTarget;
+import com.facebook.buck.parser.NoSuchBuildTargetException;
+import com.facebook.buck.rules.BuildRule;
+import com.facebook.buck.rules.BuildRuleParams;
+import com.facebook.buck.rules.BuildRuleResolver;
+import com.facebook.buck.rules.BuildRuleType;
+import com.facebook.buck.rules.BuildTargetSourcePath;
+import com.facebook.buck.rules.Description;
+import com.facebook.buck.rules.PathSourcePath;
+import com.facebook.buck.rules.SourcePath;
+import com.facebook.buck.rules.SourcePathResolver;
+import com.facebook.buck.rules.SourcePaths;
+import com.facebook.buck.rules.TargetGraph;
+import com.google.common.base.Optional;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+import org.onosproject.yang.compiler.utils.UtilConstants;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+/**
+ * Description of a Buck Yang Library.
+ */
+public class YangLibraryDescription
+ implements Description<YangLibraryDescription.Arg>, Flavored {
+ public static final BuildRuleType TYPE = BuildRuleType.of("yang_library");
+ public static final Flavor SOURCES = ImmutableFlavor.of("srcs");
+
+ private final JavacOptions defaultJavacOptions;
+ private final JavaOptions defaultJavaOptions;
+
+ public YangLibraryDescription(BuckConfig config) {
+ JavaBuckConfig javaConfig = new JavaBuckConfig(config);
+ defaultJavacOptions = javaConfig.getDefaultJavacOptions();
+ defaultJavaOptions = javaConfig.getDefaultJavaOptions();
+ }
+
+ @Override
+ public BuildRuleType getBuildRuleType() {
+ return TYPE;
+ }
+
+ @Override
+ public Arg createUnpopulatedConstructorArg() {
+ return new Arg();
+ }
+
+ @Override
+ public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph,
+ BuildRuleParams params,
+ BuildRuleResolver resolver,
+ A args)
+ throws NoSuchBuildTargetException {
+
+ SourcePathResolver pathResolver = new SourcePathResolver(resolver);
+
+ UnflavoredBuildTarget unflavoredBuildTarget =
+ params.getBuildTarget().getUnflavoredBuildTarget();
+ BuildRuleParams yangParams = params.copyWithBuildTarget(
+ BuildTargets.createFlavoredBuildTarget(
+ unflavoredBuildTarget, SOURCES));
+ BuildRule yangLib = resolver.addToIndex(new YangLibrary(yangParams, pathResolver, args.srcs));
+
+ if (params.getBuildTarget().getFlavors().contains(SOURCES)) {
+ return yangLib;
+ }
+
+ JavacOptions javacOptions = JavacOptionsFactory.create(
+ defaultJavacOptions,
+ params,
+ resolver,
+ pathResolver,
+ args
+ );
+
+
+ // Create to main compile rule.
+ BuildRuleParams javaParams = params.copyWithChanges(
+ params.getBuildTarget(),
+ Suppliers.ofInstance(
+ ImmutableSortedSet.<BuildRule>naturalOrder()
+ .add(yangLib)
+// .addAll(deps)
+ //FIXME remove when we figure out compile time deps
+ .addAll((args.deps.or(ImmutableSortedSet.<BuildTarget>of())).stream().map(resolver::getRule).collect(Collectors.toList()))
+// .addAll(BuildRules.getExportedRules(deps))
+ .addAll(pathResolver.filterBuildRuleInputs(javacOptions.getInputs(pathResolver)))
+ .build()),
+ Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>of()));
+
+ BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR);
+
+ //Add yang meta data resources to generated jar file resources.
+
+ Path rscRoot = ((YangLibrary) yangLib).getGenSrcsDirectory();
+ Path resPath = Paths.get(rscRoot + UtilConstants.SLASH + UtilConstants.YANG);
+
+ SourcePath path = new PathSourcePath(params.getProjectFilesystem(),
+ resPath);
+
+ DefaultJavaLibrary library =
+ resolver.addToIndex(
+ new DefaultJavaLibrary(
+ javaParams,
+ pathResolver,
+ ImmutableSet.of(SourcePaths.getToBuildTargetSourcePath().apply(yangLib)),
+ /* resources */ImmutableSet.of(path),
+ javacOptions.getGeneratedSourceFolderName(),
+ /* proguardConfig */ Optional.<SourcePath>absent(),
+ /* postprocessClassesCommands */ ImmutableList.<String>of(),
+ /* exportedDeps */ ImmutableSortedSet.<BuildRule>of(),
+ /* providedDeps */ ImmutableSortedSet.<BuildRule>of(),
+ /* abiJar */ new BuildTargetSourcePath(abiJarTarget),
+ javacOptions.trackClassUsage(),
+ /* additionalClasspathEntries */ ImmutableSet.<Path>of(),
+ new JavacToJarStepFactory(javacOptions, JavacOptionsAmender.IDENTITY),
+ /* resourcesRoot */ Optional.<Path>of(rscRoot),
+ /* manifestFile */ Optional.absent(),
+ /* mavenCoords */ Optional.<String>absent(),
+ /* tests */ ImmutableSortedSet.<BuildTarget>of(),
+ /* classesToRemoveFromJar */ ImmutableSet.<Pattern>of()));
+
+ resolver.addToIndex(
+ CalculateAbi.of(
+ abiJarTarget,
+ pathResolver,
+ params,
+ new BuildTargetSourcePath(library.getBuildTarget())));
+
+ return library;
+ }
+
+ @Override
+ public boolean hasFlavors(ImmutableSet<Flavor> flavors) {
+ return flavors.isEmpty() || flavors.contains(SOURCES);
+ }
+
+ public static class Arg extends JvmLibraryArg {
+ public ImmutableSortedSet<SourcePath> srcs;
+ public Optional<ImmutableSortedSet<BuildTarget>> deps;
+
+ //TODO other params here
+ }
+
+}
diff --git a/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangParsingException.java b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangParsingException.java
new file mode 100644
index 0000000..c4b9461
--- /dev/null
+++ b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangParsingException.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.
+ */
+
+package org.onosproject.yang.compiler.plugin.buck;
+
+/**
+ * Used to signal a problem parsing a Yang model.
+ */
+public class YangParsingException extends Exception {
+
+ /**
+ * Creates a YangParsingException based on another exception.
+ * @param t exception from the parser
+ */
+ public YangParsingException (Throwable t) {
+ super(t);
+ }
+
+}
diff --git a/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangStep.java b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangStep.java
new file mode 100644
index 0000000..076fd0a
--- /dev/null
+++ b/compiler/plugin/buck/src/main/java/org/onosproject/yang/compiler/plugin/buck/YangStep.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.
+ */
+package org.onosproject.yang.compiler.plugin.buck;
+
+import com.facebook.buck.io.ProjectFilesystem;
+import com.facebook.buck.model.UnflavoredBuildTarget;
+import com.facebook.buck.rules.BuildRule;
+import com.facebook.buck.step.AbstractExecutionStep;
+import com.facebook.buck.step.ExecutionContext;
+import com.facebook.buck.step.StepExecutionResult;
+import com.google.common.collect.ImmutableSortedSet;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAR;
+import static org.onosproject.yang.compiler.utils.UtilConstants.LIB;
+import static org.onosproject.yang.compiler.utils.UtilConstants.LIB_PATH;
+import static org.onosproject.yang.compiler.utils.UtilConstants.OUT;
+import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
+
+/**
+ * Buck build step to trigger Yang Java source file generation.
+ */
+public class YangStep extends AbstractExecutionStep {
+
+ private static final String DESCRIPTION = "yang-compile";
+ private final ImmutableSortedSet<BuildRule> deps;
+ private final ProjectFilesystem filesystem;
+ private final List<Path> srcs;
+ private final Path output;
+
+ YangStep(ProjectFilesystem filesystem,
+ List<Path> srcs,
+ Path genSourcesDirectory, ImmutableSortedSet<BuildRule> deps) {
+ super(DESCRIPTION);
+ this.filesystem = filesystem;
+ this.srcs = srcs;
+ this.deps = deps;
+ this.output = genSourcesDirectory;
+ }
+
+ @Override
+ public StepExecutionResult execute(ExecutionContext executionContext)
+ throws IOException, InterruptedException {
+
+ List<File> sourceFiles = srcs.stream().map(Path::toFile)
+ .collect(Collectors.toList());
+ try {
+ new YangGenerator(sourceFiles, output.toString(), getJarPaths())
+ .execute();
+ return StepExecutionResult.SUCCESS;
+ } catch (YangParsingException e) {
+ executionContext.getConsole().printErrorText(e.getMessage());
+ return StepExecutionResult.ERROR;
+ }
+ }
+
+ private List<String> getJarPaths() {
+ StringBuilder builder;
+ List<String> depJarPaths = new ArrayList<>();
+ String[] array;
+ UnflavoredBuildTarget uBt;
+ if (deps != null) {
+ for (BuildRule rule : deps) {
+ if (!rule.getBuildTarget().getFullyQualifiedName()
+ .contains(LIB_PATH)) {
+ builder = new StringBuilder();
+ //build absolute path for jar file
+ builder.append(filesystem.getRootPath().toString()).append(SLASH)
+ .append(filesystem.getBuckPaths().getGenDir())
+ .append(SLASH);
+ uBt = rule.getBuildTarget().getUnflavoredBuildTarget();
+ array = uBt.getBaseName().split(SLASH);
+ for (int i = 2; i < array.length; i++) {
+ builder.append(array[i]).append(SLASH);
+ }
+ builder.append(LIB).append(uBt.getShortName())
+ .append(OUT).append(SLASH)
+ .append(uBt.getShortName()).append(PERIOD + JAR);
+ depJarPaths.add(builder.toString());
+ }
+ }
+ }
+ return depJarPaths;
+ }
+}