Skip to content

Commit

Permalink
Goal bundle replaces -SNAPSHOT with timestamp derived value overflowi…
Browse files Browse the repository at this point in the history
…ng the Integer.MAX_VALUE
  • Loading branch information
reda-alaoui authored and ctron committed Jun 24, 2024
1 parent 98ef444 commit 9dfee4c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/main/java/de/dentrassi/maven/osgi/dp/AbstractDpMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@

import static java.lang.String.format;

import com.google.common.io.ByteStreams;
import de.dentrassi.maven.osgi.dp.internal.ArtifactWalker;
import de.dentrassi.maven.osgi.dp.internal.ProjectWalker;
import de.dentrassi.maven.osgi.dp.internal.TychoWalker;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -34,7 +36,6 @@
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
Expand All @@ -59,16 +60,8 @@
import org.eclipse.tycho.core.TychoProject;
import org.osgi.framework.Version;

import com.google.common.io.ByteStreams;

import de.dentrassi.maven.osgi.dp.internal.ArtifactWalker;
import de.dentrassi.maven.osgi.dp.internal.ProjectWalker;
import de.dentrassi.maven.osgi.dp.internal.TychoWalker;

public abstract class AbstractDpMojo extends AbstractMojo {

private static final DateFormat TIMESTAMP_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");

/**
* The maven project
*/
Expand Down Expand Up @@ -324,7 +317,7 @@ private Version makeQualifiedVersion() {

String version = this.project.getVersion();
if (version.endsWith("-SNAPSHOT")) {
version = version.replaceAll("-SNAPSHOT$", "." + TIMESTAMP_FORMAT.format(this.session.getStartTime()));
version = version.replaceAll("-SNAPSHOT$", "." + this.session.getStartTime().toInstant().getEpochSecond());
}

return new Version(version);
Expand Down

0 comments on commit 9dfee4c

Please sign in to comment.