Search in sources :

Example 1 with JvmAssembly

use of org.gradle.jvm.internal.JvmAssembly in project gradle by gradle.

the class JvmLocalLibraryMetaDataAdapter method createLocalComponentMetaData.

@Override
@SuppressWarnings("unchecked")
public DefaultLibraryLocalComponentMetadata createLocalComponentMetaData(Binary selectedBinary, String projectPath, boolean toAssembly) {
    EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage = new EnumMap<UsageKind, Iterable<DependencySpec>>(UsageKind.class);
    EnumMap<UsageKind, List<PublishArtifact>> artifacts = new EnumMap<UsageKind, List<PublishArtifact>>(UsageKind.class);
    initializeUsages(dependenciesPerUsage, artifacts);
    if (selectedBinary instanceof JarBinarySpecInternal) {
        JarBinarySpecInternal jarBinarySpec = (JarBinarySpecInternal) selectedBinary;
        createJarBinarySpecLocalComponentMetaData(artifacts, jarBinarySpec, dependenciesPerUsage, toAssembly);
    }
    if (selectedBinary instanceof WithJvmAssembly) {
        // a local component that provides a JVM assembly
        JvmAssembly assembly = ((WithJvmAssembly) selectedBinary).getAssembly();
        createJvmAssemblyLocalComponentMetaData(artifacts, assembly, dependenciesPerUsage, toAssembly);
    }
    return createResolvedMetaData((BinarySpecInternal) selectedBinary, projectPath, dependenciesPerUsage, artifacts);
}
Also used : JarBinarySpecInternal(org.gradle.jvm.internal.JarBinarySpecInternal) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) JvmAssembly(org.gradle.jvm.internal.JvmAssembly) DependencySpec(org.gradle.platform.base.DependencySpec) LinkedList(java.util.LinkedList) List(java.util.List) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) EnumMap(java.util.EnumMap)

Example 2 with JvmAssembly

use of org.gradle.jvm.internal.JvmAssembly in project gradle by gradle.

the class JvmTestSuiteBasePlugin method createJvmTestSuiteTasks.

@BinaryTasks
void createJvmTestSuiteTasks(ModelMap<Task> tasks, final JvmTestSuiteBinarySpecInternal binary, @Path("buildDir") final File buildDir) {
    final JvmAssembly jvmAssembly = ((WithJvmAssembly) binary).getAssembly();
    tasks.create(testTaskNameFor(binary), Test.class, new Action<Test>() {

        @Override
        public void execute(final Test test) {
            test.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
            test.setDescription(String.format("Runs %s.", WordUtils.uncapitalize(binary.getDisplayName())));
            test.dependsOn(jvmAssembly);
            test.setTestClassesDirs(new SimpleFileCollection(binary.getClassesDir()));
            test.setClasspath(binary.getRuntimeClasspath());
            configureReports(binary, test);
        }

        private void configureReports(JvmTestSuiteBinarySpecInternal binary, Test test) {
            // todo: improve configuration of reports
            TestTaskReports reports = test.getReports();
            File reportsDirectory = new File(buildDir, "reports");
            File reportsOutputDirectory = binary.getNamingScheme().getOutputDirectory(reportsDirectory);
            File htmlDir = new File(reportsOutputDirectory, "tests");
            File xmlDir = new File(buildDir, "test-results");
            File xmlDirOutputDirectory = binary.getNamingScheme().getOutputDirectory(xmlDir);
            File binDir = new File(xmlDirOutputDirectory, "binary");
            reports.getHtml().setDestination(htmlDir);
            reports.getJunitXml().setDestination(xmlDirOutputDirectory);
            test.setBinResultsDir(binDir);
        }
    });
}
Also used : TestTaskReports(org.gradle.api.tasks.testing.TestTaskReports) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) Test(org.gradle.api.tasks.testing.Test) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) JvmAssembly(org.gradle.jvm.internal.JvmAssembly) SimpleFileCollection(org.gradle.api.internal.file.collections.SimpleFileCollection) JvmTestSuiteBinarySpecInternal(org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal) File(java.io.File) BinaryTasks(org.gradle.platform.base.BinaryTasks)

Aggregations

JvmAssembly (org.gradle.jvm.internal.JvmAssembly)2 WithJvmAssembly (org.gradle.jvm.internal.WithJvmAssembly)2 File (java.io.File)1 EnumMap (java.util.EnumMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 DefaultPublishArtifact (org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact)1 SimpleFileCollection (org.gradle.api.internal.file.collections.SimpleFileCollection)1 Test (org.gradle.api.tasks.testing.Test)1 TestTaskReports (org.gradle.api.tasks.testing.TestTaskReports)1 JarBinarySpecInternal (org.gradle.jvm.internal.JarBinarySpecInternal)1 JvmTestSuiteBinarySpecInternal (org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal)1 BinaryTasks (org.gradle.platform.base.BinaryTasks)1 DependencySpec (org.gradle.platform.base.DependencySpec)1