Search in sources :

Example 1 with PublicationInternal

use of org.gradle.api.publish.internal.PublicationInternal in project gradle by gradle.

the class GenerateModuleMetadata method run.

@TaskAction
void run() {
    File file = outputFile.get().getAsFile();
    PublicationInternal publication = (PublicationInternal) this.publication.get();
    List<PublicationInternal> publications = Cast.uncheckedCast(this.publications.get());
    try {
        Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf8"));
        try {
            new ModuleMetadataFileGenerator(getBuildInvocationScopeId(), getProjectDependencyPublicationResolver()).generateTo(publication, publications, writer);
        } finally {
            writer.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException("Could not generate metadata file " + outputFile.get(), e);
    }
}
Also used : ModuleMetadataFileGenerator(org.gradle.api.publish.internal.ModuleMetadataFileGenerator) PublicationInternal(org.gradle.api.publish.internal.PublicationInternal) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) File(java.io.File) OutputFile(org.gradle.api.tasks.OutputFile) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) Writer(java.io.Writer) BufferedWriter(java.io.BufferedWriter) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ModuleMetadataFileGenerator (org.gradle.api.publish.internal.ModuleMetadataFileGenerator)1 PublicationInternal (org.gradle.api.publish.internal.PublicationInternal)1 OutputFile (org.gradle.api.tasks.OutputFile)1 TaskAction (org.gradle.api.tasks.TaskAction)1