Skip to content

Commit

Permalink
Remove anonymous implementation of PublishArtifact with usage of arti…
Browse files Browse the repository at this point in the history
…fact(Object) to add the jar
  • Loading branch information
tresat committed Jan 23, 2023
1 parent bfe8814 commit 87840a2
Showing 1 changed file with 1 addition and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationPublications;
import org.gradle.api.artifacts.PublishArtifact;
import org.gradle.api.artifacts.component.ComponentIdentifier;
import org.gradle.api.artifacts.component.ProjectComponentIdentifier;
import org.gradle.api.artifacts.dsl.DependencyHandler;
Expand All @@ -15,7 +14,6 @@
import org.gradle.api.internal.artifacts.ArtifactAttributes;
import org.gradle.api.plugins.scala.ScalaPlugin;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskDependency;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.playframework.extensions.PlayExtension;
Expand All @@ -27,10 +25,7 @@
import org.gradle.playframework.tasks.TwirlCompile;
import org.gradle.util.VersionNumber;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;

import static org.gradle.api.plugins.BasePlugin.ASSEMBLE_TASK_NAME;
import static org.gradle.api.plugins.JavaPlugin.*;
Expand Down Expand Up @@ -134,44 +129,8 @@ private TaskProvider<Jar> createAssetsJarTask(Project project) {

private void registerOutgoingArtifact(Project project, TaskProvider<Jar> assetsJarTask) {
Configuration runtimeElementsConfiguration = project.getConfigurations().getByName(RUNTIME_ELEMENTS_CONFIGURATION_NAME);
PublishArtifact jarArtifact = new PublishArtifact() {
@Override
public String getName() {
return assetsJarTask.get().getArchiveFileName().get();
}

@Override
public String getExtension() {
return "jar";
}

@Override
public String getType() {
return "jar";
}

@Override
public String getClassifier() {
return assetsJarTask.get().getArchiveClassifier().get();
}

@Override
public File getFile() {
return assetsJarTask.get().getArchiveFile().get().getAsFile();
}

@Override
public Date getDate() {
return new Date();
}

@Override
public TaskDependency getBuildDependencies() {
return task -> Collections.singleton(assetsJarTask.get());
}
};
ConfigurationPublications publications = runtimeElementsConfiguration.getOutgoing();
publications.getArtifacts().add(jarArtifact);
publications.artifact(assetsJarTask);
publications.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.JAR_TYPE);
}

Expand Down

0 comments on commit 87840a2

Please sign in to comment.