Skip to content

Commit

Permalink
add setupPublishRepository for RepositoryHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
LCLPYT committed Jun 15, 2023
1 parent 6de2d57 commit bdec36f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package work.lclpnet.build.ext;

import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.provider.Property;
import org.gradle.api.publish.PublishingExtension;

Expand All @@ -15,7 +16,11 @@ public interface BuildUtilsExtension {

Properties loadProperties(Object src);

void setupPublishRepository(PublishingExtension extension, Properties properties);
void setupPublishRepository(RepositoryHandler repositories, Properties properties);

default void setupPublishRepository(PublishingExtension extension, Properties properties) {
extension.repositories(repositories -> setupPublishRepository(repositories, properties));
}

default void setupPublishRepository(PublishingExtension extension) {
setupPublishRepository(extension, new Properties());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package work.lclpnet.build.ext;

import org.gradle.api.Project;
import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.provider.Property;
import org.gradle.api.publish.PublishingExtension;
import work.lclpnet.build.util.GitVersionResolver;

import java.io.File;
Expand Down Expand Up @@ -113,8 +113,8 @@ private synchronized String fetchLatestTag() {
}

@Override
public void setupPublishRepository(PublishingExtension extension, Properties props) {
extension.repositories(repositories -> repositories.maven(repo -> {
public void setupPublishRepository(RepositoryHandler repositories, Properties props) {
repositories.maven(repo -> {
Map<String, String> env = System.getenv();

if (Stream.of("DEPLOY_URL", "DEPLOY_USER", "DEPLOY_PASSWORD").allMatch(env::containsKey)) {
Expand All @@ -134,6 +134,6 @@ public void setupPublishRepository(PublishingExtension extension, Properties pro
} else {
repo.setUrl("file:///" + project.getProjectDir().getAbsolutePath() + "/repo");
}
}));
});
}
}

0 comments on commit bdec36f

Please sign in to comment.