Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class);
jar.setDescription("Assembles a jar archive containing the main classes.");
jar.setGroup(BasePlugin.BUILD_GROUP);
jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());
ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar);
Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME);
runtimeConfiguration.getArtifacts().add(jarArtifact);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact);
project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies()));