/** * Create a {@link PublishArtifact} for a jar created by a {@link Jar} task * * We use this instead of {@link ArchivePublishArtifact} because we can add the unresolved task dependency by name, * thus avoiding a direct dependency on the task. * * @param project Project to create artifact for * @param name Name of the new artifact * @param classifier Classifier for new artifact * @param type Type of new artifact * @param extension Extension of new artifact * @param producingTask Task that produces the artifact * @return Publish artifact for the jar */ public static PublishArtifact createJarPublishArtifact(Project project, String name, @Nullable String classifier, String type, String extension, Jar producingTask) { BasePluginConvention baseConvention = project.getConvention().getPlugin(BasePluginConvention.class); String jarName = FILE_PART_JOINER.join(name, project.getVersion(), classifier) + "." + extension; File jarFile = baseConvention.getLibsDir().toPath().resolve(jarName).toFile(); DefaultPublishArtifact artifact = new DefaultPublishArtifact(name, extension, type, classifier, null, jarFile, producingTask); return artifact; }
/** * Get the library directory * * @return Library directory */ public File getLibsDir() { BasePluginConvention baseConvention = this.project.getConvention().getPlugin(BasePluginConvention.class); File libsDir = Validate.notNull(baseConvention.getLibsDir(), "The libs dir must not be null"); return libsDir; }
/** * Create a {@link PublishArtifact} for a jar created by a {@link Jar} task * * We use this instead of {@link ArchivePublishArtifact} because we can add the unresolved task dependency by name, * thus avoiding a direct dependency on the task. * * @param project Project to create artifact for * @param name Name of the new artifact * @param classifier Classifier for new artifact * @param type Type of new artifact * @param extension Extension of new artifact * @param producingTask Task that produces the artifact * @return Publish artifact for the jar */ public static PublishArtifact createJarPublishArtifact(Project project, String name, @Nullable String classifier, String type, String extension, Jar producingTask) { BasePluginConvention baseConvention = project.getConvention().getPlugin(BasePluginConvention.class); String jarName = FILE_PART_JOINER.join(name, project.getVersion(), classifier) + "." + extension; File jarFile = baseConvention.getLibsDir().toPath().resolve(jarName).toFile(); DefaultPublishArtifact artifact = new DefaultPublishArtifact(name, extension, type, classifier, null, jarFile, producingTask); return artifact; }
/** * Get the library directory * * @return Library directory */ public File getLibsDir() { BasePluginConvention baseConvention = this.project.getConvention().getPlugin(BasePluginConvention.class); File libsDir = Validate.notNull(baseConvention.getLibsDir(), "The libs dir must not be null"); return libsDir; }