public static DependentComponentsRenderableDependency of( ComponentSpec componentSpec, ComponentSpecInternal internalProtocol, LinkedHashSet<DependentComponentsRenderableDependency> children) { ComponentSpecIdentifier id = internalProtocol.getIdentifier(); String name = DependentComponentsUtils.getBuildScopedTerseName(id); String description = componentSpec.getDisplayName(); boolean buildable = true; if (componentSpec instanceof VariantComponentSpec) { // Consider variant aware components with no buildable binaries as non-buildables VariantComponentSpec variantComponentSpec = (VariantComponentSpec) componentSpec; buildable = Iterables.any( variantComponentSpec.getBinaries().values(), new Predicate<BinarySpec>() { @Override public boolean apply(BinarySpec binarySpec) { return binarySpec.isBuildable(); } }); } boolean testSuite = false; return new DependentComponentsRenderableDependency( id, name, description, buildable, testSuite, children); }
@Defaults void configureJarBinaries( final ComponentSpec jvmLibrary, final ProjectLayout projectLayout, final JavaToolChainRegistry toolChains) { jvmLibrary .getBinaries() .withType(JvmBinarySpec.class) .beforeEach( new Action<JvmBinarySpec>() { @Override public void execute(JvmBinarySpec jvmBinary) { BinaryNamingScheme namingScheme = ((BinarySpecInternal) jvmBinary).getNamingScheme(); jvmBinary.setClassesDir( namingScheme.getOutputDirectory(projectLayout.getBuildDir(), "classes")); jvmBinary.setResourcesDir( namingScheme.getOutputDirectory(projectLayout.getBuildDir(), "resources")); } }); jvmLibrary .getBinaries() .withType(JarBinarySpecInternal.class) .beforeEach( new Action<JarBinarySpecInternal>() { @Override public void execute(JarBinarySpecInternal jarBinary) { String libraryName = jarBinary.getId().getLibraryName(); File jarsDir = jarBinary .getNamingScheme() .getOutputDirectory(projectLayout.getBuildDir(), "jars"); jarBinary.setJarFile(new File(jarsDir, String.format("%s.jar", libraryName))); jarBinary.setApiJarFile( new File(jarsDir, String.format("api/%s.jar", libraryName))); jarBinary.setToolChain(toolChains.getForPlatform(jarBinary.getTargetPlatform())); } }); }
@Defaults void configureJarBinaries( final ComponentSpec jvmLibrary, BuildDirHolder buildDirHolder, final JavaToolChainRegistry toolChains) { final File binariesDir = new File(buildDirHolder.getDir(), "jars"); final File classesDir = new File(buildDirHolder.getDir(), "classes"); jvmLibrary .getBinaries() .withType(JarBinarySpec.class) .beforeEach( new Action<JarBinarySpec>() { @Override public void execute(JarBinarySpec jarBinary) { String jarBinaryName = jarBinary.getName(); int idx = jarBinaryName.lastIndexOf("Jar"); String apiJarBinaryName = idx > 0 ? jarBinaryName.substring(0, idx) + "ApiJar" : jarBinaryName + "ApiJar"; String libraryName = jarBinary.getId().getLibraryName(); File outputDir = new File(classesDir, jarBinaryName); jarBinary.setClassesDir(outputDir); jarBinary.setResourcesDir(outputDir); jarBinary.setJarFile( new File( binariesDir, String.format("%s%s%s.jar", jarBinaryName, File.separator, libraryName))); jarBinary.setApiJarFile( new File( binariesDir, String.format( "%s%s%s.jar", apiJarBinaryName, File.separator, libraryName))); jarBinary.setToolChain(toolChains.getForPlatform(jarBinary.getTargetPlatform())); } }); }