From d411566c45bd4f4fe2d2723e12b373a3352bb902 Mon Sep 17 00:00:00 2001 From: reger24 Date: Sun, 16 Jan 2022 05:36:24 +0100 Subject: [PATCH] Obsolete since replacement of Maven by Gradle build script --- libbuild/GitRevMavenTask/.gitignore | 4 - libbuild/GitRevMavenTask/pom.xml | 137 ---------------- .../GitRevMavenTask/src/GitRevMavenTask.java | 146 ------------------ 3 files changed, 287 deletions(-) delete mode 100755 libbuild/GitRevMavenTask/.gitignore delete mode 100644 libbuild/GitRevMavenTask/pom.xml delete mode 100644 libbuild/GitRevMavenTask/src/GitRevMavenTask.java diff --git a/libbuild/GitRevMavenTask/.gitignore b/libbuild/GitRevMavenTask/.gitignore deleted file mode 100755 index d98981cc4..000000000 --- a/libbuild/GitRevMavenTask/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -/.classpath -/.project -/.settings/ diff --git a/libbuild/GitRevMavenTask/pom.xml b/libbuild/GitRevMavenTask/pom.xml deleted file mode 100644 index 656f8eb68..000000000 --- a/libbuild/GitRevMavenTask/pom.xml +++ /dev/null @@ -1,137 +0,0 @@ - - 4.0.0 - - net.yacy - maven-plugin-gitrevisionnumber - 1.1 - maven-plugin - YaCy - Build Number Maven Plugin - This plugin gives you a Git repository release number. in the format 9000 as maven property "releaseNr" and a Git repository timestamp as Maven property "DSTAMP" in the format yyyymmdd - - http://www.yacy.net - - - scm:git:https://github.com/yacy/yacy_search_server.git - https://github.com/yacy/yacy_search_server - - - - - Michael Peter Christen - - - - - UTF-8 - - - - src - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - 1.7 - 1.7 - - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.2 - - - 1 - validate - - create - - - - - false - false - 5 - 9000 - - {0,date,yyyyMMdd}-{1} - - timestamp - scmVersion - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - runtime - java - - -classpath - - - - - - org.apache.maven.plugins - maven-plugin-plugin - 3.2 - - - true - - - - mojo-descriptor - - descriptor - - - - - - - - - - - - - org.apache.maven - maven-plugin-api - 3.1.0 - - - org.eclipse.jgit - org.eclipse.jgit - 4.5.0.201609210915-r - jar - - - org.apache.maven - maven-project - 3.0-alpha-2 - - - org.apache.maven.plugin-tools - maven-plugin-annotations - 3.2 - - - org.apache.maven - maven-core - 3.1.1 - - - diff --git a/libbuild/GitRevMavenTask/src/GitRevMavenTask.java b/libbuild/GitRevMavenTask/src/GitRevMavenTask.java deleted file mode 100644 index 4c110982f..000000000 --- a/libbuild/GitRevMavenTask/src/GitRevMavenTask.java +++ /dev/null @@ -1,146 +0,0 @@ - -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugins.annotations.Component; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; - -/** - * Maven plugin to create property with YaCy release number, - * a 4 digit number based on commits to the Git repository - * - */ -@Mojo(name = "create", defaultPhase = LifecyclePhase.INITIALIZE) -public class GitRevMavenTask extends AbstractMojo { - - @Component - private MavenProject project; - /** - * Name of the buildNumber property - * - * parameter expression="${maven.buildNumber.buildNumberPropertyName}" - * default-value="releaseNr" - */ - @Parameter - private String branchPropertyName = "branch"; - @Parameter - private String buildNumberPropertyName = "releaseNr"; - @Parameter - private String commitDatePropertyName = "DSTAMP"; - - Log log = this.getLog(); - - public void setBuildNumberPropertyName(String revprop) { - this.buildNumberPropertyName = revprop; - } - - public void setCommitDatePropertyName(String dateprop) { - this.commitDatePropertyName = dateprop; - } - - @Override - public void execute() throws MojoExecutionException { - - String branch = null; - String revision = null; - String lastTag = null; - String commitDate = null; - - Repository repo = null; - Git git = null; - RevWalk walk = null; - try { - - final File src = project.getBasedir(); // set Git root path to project root - repo = new FileRepositoryBuilder().readEnvironment() - .findGitDir(src).build(); - branch = repo.getBranch(); - branch = "master".equals(branch) ? "" : "_" + branch; - final ObjectId head = repo.resolve("HEAD"); - - git = new Git(repo); - - final List tags = git.tagList().call(); - - walk = new RevWalk(repo); - final RevCommit headCommit = walk.parseCommit(head); - final SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); - commitDate = df.format(headCommit.getAuthorIdent().getWhen()); - walk.markStart(headCommit); - int distance = 0; - - /* Peel known tags */ - final List peeledTags = new ArrayList<>(); - for (final Ref tag : tags) { - peeledTags.add(repo.peel(tag)); - } - - /* Look for the last tag commit and calculate distance with the HEAD commit */ - for (final RevCommit commit : walk) { - for (final Ref tag : peeledTags) { - if (commit.equals(tag.getPeeledObjectId()) || commit.equals(tag.getObjectId())) { - lastTag = commit.getShortMessage(); - break; - } - } - if (lastTag != null || distance++ > 90999) { - break; - } - } - walk.dispose(); - if (lastTag == null) { - revision = "0000"; - } else { - revision = Integer.toString(distance + 9000); - } - } catch (final IOException e) { - e.printStackTrace(); - } catch (GitAPIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - /* In all cases, properly release resources */ - if(walk != null) { - walk.close(); - } - if(git != null) { - git.close(); - } - if(repo != null) { - repo.close(); - } - } - if (project != null) { - project.getProperties().put(this.branchPropertyName, branch); - log.info("GitrevMavenTask: set property " + this.branchPropertyName + "='" + branch + "'"); - project.getProperties().put(this.buildNumberPropertyName, revision); - log.info("GitrevMavenTask: set property " + this.buildNumberPropertyName + "=" + revision); - project.getProperties().put(this.commitDatePropertyName, commitDate); - log.info("GitrevMavenTask: set property " + this.commitDatePropertyName + "=" + commitDate); - } else { - log.error("GitrevMavenTask: no Maven project"); - System.out.println(this.branchPropertyName + "=" + branch); - System.out.println(this.buildNumberPropertyName + "=" + revision); - System.out.println(this.commitDatePropertyName + "=" + commitDate); - } - } - - -}