Skip to content

Commit

Permalink
Windows Support for Maven Plugin (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbloder authored Jun 29, 2023
1 parent 2bcb9a0 commit 14abc19
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

### Features

- Add support for building on Windows ([#7](https://github.com/getsentry/sentry-maven-plugin/pull/7))

### Fixes

- Also use `url` and `authToken` for upload command ([#7](https://github.com/getsentry/sentry-maven-plugin/pull/7))

## 0.0.2

### Features
Expand Down
2 changes: 1 addition & 1 deletion examples/sentry-maven-plugin-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>6.19.1-SNAPSHOT</version>
<version>6.24.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
24 changes: 18 additions & 6 deletions src/main/java/io/sentry/UploadSourceBundleMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import static org.twdata.maven.mojoexecutor.MojoExecutor.*;

Expand Down Expand Up @@ -129,6 +130,13 @@ private void uploadSourceBundle(File sourceBundleTargetDir) throws MojoExecution
command.add("--log-level=debug");
}

if (url != null) {
command.add("--url=" + url);
}
if (authToken != null) {
command.add("--auth-token=" + authToken);
}

command.add("debug-files");
command.add("upload");
command.add("--type=jvm");
Expand All @@ -144,7 +152,11 @@ private void uploadSourceBundle(File sourceBundleTargetDir) throws MojoExecution
}

private void runSentryCli(String sentryCliCommand) throws MojoExecutionException {
// TODO probably won't work on windows
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");

String executable = isWindows ? "cmd.exe" : "/bin/sh";
String cArg = isWindows ? "/c" : "-c";

executeMojo(
plugin(
groupId("org.apache.maven.plugins"),
Expand All @@ -156,9 +168,9 @@ private void runSentryCli(String sentryCliCommand) throws MojoExecutionException
element(name("target"),
element(name("exec"),
attributes(
attribute("executable", "/bin/sh")
attribute("executable", executable)
),
element(name("arg"), attributes(attribute("value", "-c"))),
element(name("arg"), attributes(attribute("value", cArg))),
element(name("arg"), attributes(attribute("value", sentryCliExecutablePath + " " + sentryCliCommand)))
)
)
Expand Down

0 comments on commit 14abc19

Please sign in to comment.