use of com.facebook.buck.model.UnflavoredBuildTarget in project buck by facebook.
the class Publisher method publish.
public ImmutableSet<DeployResult> publish(SourcePathResolver pathResolver, ImmutableSet<MavenPublishable> publishables) throws DeploymentException {
ImmutableListMultimap<UnflavoredBuildTarget, UnflavoredBuildTarget> duplicateBuiltinBuileRules = checkForDuplicatePackagedDeps(publishables);
if (duplicateBuiltinBuileRules.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("Duplicate transitive dependencies for publishable libraries found! This means");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("that the following libraries would have multiple copies if these libraries were");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("used together. The can be resolved by adding a maven URL to each target listed");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("below:");
for (UnflavoredBuildTarget unflavoredBuildTarget : duplicateBuiltinBuileRules.keySet()) {
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append(unflavoredBuildTarget.getFullyQualifiedName());
sb.append(" (referenced by these build targets: ");
Joiner.on(", ").appendTo(sb, duplicateBuiltinBuileRules.get(unflavoredBuildTarget));
sb.append(")");
}
throw new DeploymentException(sb.toString());
}
ImmutableSet.Builder<DeployResult> deployResultBuilder = ImmutableSet.builder();
for (MavenPublishable publishable : publishables) {
DefaultArtifact coords = new DefaultArtifact(Preconditions.checkNotNull(publishable.getMavenCoords().get(), "No maven coordinates specified for published rule ", publishable));
Path relativePathToOutput = pathResolver.getRelativePath(Preconditions.checkNotNull(publishable.getSourcePathToOutput(), "No path to output present in ", publishable));
File mainItem = publishable.getProjectFilesystem().resolve(relativePathToOutput).toFile();
if (!coords.getClassifier().isEmpty()) {
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem)));
}
try {
// If this is the "main" artifact (denoted by lack of classifier) generate and publish
// pom alongside
File pom = Pom.generatePomFile(pathResolver, publishable).toFile();
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem, pom)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return deployResultBuilder.build();
}
use of com.facebook.buck.model.UnflavoredBuildTarget in project buck by facebook.
the class Publisher method checkForDuplicatePackagedDeps.
/**
* Checks for any packaged dependencies that exist between more than one of the targets that we
* are trying to publish.
* @return A multimap of dependency build targets and the publishable build targets that have them
* included in the final package that will be uploaded.
*/
private ImmutableListMultimap<UnflavoredBuildTarget, UnflavoredBuildTarget> checkForDuplicatePackagedDeps(ImmutableSet<MavenPublishable> publishables) {
// First build the multimap of the builtin dependencies and the publishable targets that use
// them.
Multimap<UnflavoredBuildTarget, UnflavoredBuildTarget> builtinDeps = HashMultimap.create();
for (MavenPublishable publishable : publishables) {
for (BuildRule buildRule : publishable.getPackagedDependencies()) {
builtinDeps.put(buildRule.getBuildTarget().getUnflavoredBuildTarget(), publishable.getBuildTarget().getUnflavoredBuildTarget());
}
}
// Now, check for any duplicate uses, and if found, return them.
ImmutableListMultimap.Builder<UnflavoredBuildTarget, UnflavoredBuildTarget> builder = ImmutableListMultimap.builder();
for (UnflavoredBuildTarget buildTarget : builtinDeps.keySet()) {
Collection<UnflavoredBuildTarget> publishablesUsingBuildTarget = builtinDeps.get(buildTarget);
if (publishablesUsingBuildTarget.size() > 1) {
builder.putAll(buildTarget, publishablesUsingBuildTarget);
}
}
return builder.build();
}
use of com.facebook.buck.model.UnflavoredBuildTarget in project buck by facebook.
the class BuildConfigsTest method testCustomGenerateBuildConfigDotJavaWithConstantExpressions.
@Test
public void testCustomGenerateBuildConfigDotJavaWithConstantExpressions() {
BuildConfigFields customValues = BuildConfigFields.fromFieldDeclarations(ImmutableList.of("String KEYSTORE_TYPE = \"release\"", "int BUILD_NUMBER = 42", "long BUILD_DATE = 1404321113076000L", "float THREE = 3.0F", "boolean DEBUG = false", "int EXOPACKAGE_FLAGS = 0"));
String expectedJavaCode = "// Generated by //java/com/example:build_config. DO NOT MODIFY.\n" + "package com.example;\n" + "public class BuildConfig {\n" + " private BuildConfig() {}\n" + " public static final String KEYSTORE_TYPE = \"release\";\n" + " public static final int BUILD_NUMBER = 42;\n" + " public static final long BUILD_DATE = 1404321113076000L;\n" + " public static final float THREE = 3.0F;\n" + " public static final boolean DEBUG = false;\n" + " public static final int EXOPACKAGE_FLAGS = 0;\n" + " public static final boolean IS_EXOPACKAGE = false;\n" + "}\n";
UnflavoredBuildTarget source = BuildTargetFactory.newInstance("//java/com/example:build_config").getUnflavoredBuildTarget();
String observedJavaCode = BuildConfigs.generateBuildConfigDotJava(source, "com.example", /* useConstantExpressions */
true, customValues);
assertEquals(expectedJavaCode, observedJavaCode);
}
use of com.facebook.buck.model.UnflavoredBuildTarget in project buck by facebook.
the class ProjectGenerator method getSingleCopyFilesBuildPhase.
private PBXCopyFilesBuildPhase getSingleCopyFilesBuildPhase(CopyFilePhaseDestinationSpec destinationSpec, Iterable<TargetNode<?, ?>> targetNodes) {
PBXCopyFilesBuildPhase copyFilesBuildPhase = new PBXCopyFilesBuildPhase(destinationSpec);
HashSet<UnflavoredBuildTarget> frameworkTargets = new HashSet<UnflavoredBuildTarget>();
for (TargetNode<?, ?> targetNode : targetNodes) {
PBXFileReference fileReference = getLibraryFileReference(targetNode);
PBXBuildFile buildFile = new PBXBuildFile(fileReference);
if (fileReference.getExplicitFileType().equals(Optional.of("wrapper.framework"))) {
UnflavoredBuildTarget buildTarget = targetNode.getBuildTarget().getUnflavoredBuildTarget();
if (frameworkTargets.contains(buildTarget)) {
continue;
}
frameworkTargets.add(buildTarget);
NSDictionary settings = new NSDictionary();
settings.put("ATTRIBUTES", new String[] { "CodeSignOnCopy", "RemoveHeadersOnCopy" });
buildFile.setSettings(Optional.of(settings));
}
copyFilesBuildPhase.getFiles().add(buildFile);
}
return copyFilesBuildPhase;
}
Aggregations