Skip to content

Commit

Permalink
Added Plugin repository and fixed tmp handling. (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerg Schad authored and unterstein committed Sep 26, 2017
1 parent 20e0f9f commit d7c0555
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>dcos</groupId>
<artifactId>dcos-maven-plugin</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.5</version>
<packaging>maven-plugin</packaging>

<name>mvn-plugin Maven Plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion samples/jee-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<plugin>
<groupId>dcos</groupId>
<artifactId>dcos-maven-plugin</artifactId>
<version>0.4</version>
<version>0.5</version>
<configuration>
<dcosUrl>https://frontend-elasticl-lgydh6t853qv-753743843.eu-central-1.elb.amazonaws.com/</dcosUrl>
<ignoreSslCertificate>true</ignoreSslCertificate>
Expand Down
2 changes: 1 addition & 1 deletion samples/simple-group-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<plugin>
<groupId>dcos</groupId>
<artifactId>dcos-maven-plugin</artifactId>
<version>0.4</version>
<version>0.5</version>
<configuration>
<dcosUrl>https://frontend-elasticl-lgydh6t853qv-753743843.eu-central-1.elb.amazonaws.com/</dcosUrl>
<appDefinitionFile>group-definition.json</appDefinitionFile>
Expand Down
2 changes: 1 addition & 1 deletion samples/simple-pod-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<plugin>
<groupId>dcos</groupId>
<artifactId>dcos-maven-plugin</artifactId>
<version>0.4</version>
<version>0.5</version>
<configuration>
<dcosUrl>https://frontend-elasticl-lgydh6t853qv-753743843.eu-central-1.elb.amazonaws.com/</dcosUrl>
<appDefinitionFile>pod-definition.json</appDefinitionFile>
Expand Down
2 changes: 1 addition & 1 deletion samples/simple-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<plugin>
<groupId>dcos</groupId>
<artifactId>dcos-maven-plugin</artifactId>
<version>0.4</version>
<version>0.5</version>
<configuration>
<dcosUrl>https://junterste-elasticl-wzqyi9j6o2f2-484663919.eu-central-1.elb.amazonaws.com/</dcosUrl>
<ignoreSslCertificate>true</ignoreSslCertificate>
Expand Down
14 changes: 11 additions & 3 deletions samples/spring-boot-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
<version>1.4.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<pluginRepositories>
<pluginRepository>
<id>mesosphere-repo</id>
<name>Mesosphere Repo</name>
<url>http://downloads.mesosphere.io/maven</url>
</pluginRepository>
</pluginRepositories>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -46,10 +54,10 @@
<plugin>
<groupId>dcos</groupId>
<artifactId>dcos-maven-plugin</artifactId>
<version>0.4</version>
<version>0.5</version>
<configuration>
<dcosUrl>https://joerg-a6u-elasticl-u301awdkkf3s-514314542.us-west-2.elb.amazonaws.com/</dcosUrl>
<nexusUrl>35.163.44.101:20684</nexusUrl>
<dcosUrl>https://joerg-aja-elasticl-10m9r46esrku6-1483268829.us-west-2.elb.amazonaws.com</dcosUrl>
<nexusUrl>34.212.126.213:29159</nexusUrl>
<ignoreSslCertificate>true</ignoreSslCertificate>
</configuration>
</plugin>
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/dcos/DcosDeployUCRMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class DcosDeployUCRMojo extends AbstractDcosMojo {

public void execute() throws MojoExecutionException {
CloseableHttpClient client = null;
Path tmpPath = null;
File tmpFile = null;
try {
getLog().info("About to execute DC/OS deployUCR");
logConfiguration();
Expand All @@ -44,8 +44,8 @@ public void execute() throws MojoExecutionException {
throw new RuntimeException("Artifact does not exist. You need to package first. Did you run `mvn package dcos:deployUCR`?");
}

tmpPath = File.createTempFile("ucr-deploy", "json").toPath();
Files.copy(appDefinitionFile.toPath(), tmpPath, REPLACE_EXISTING);
tmpFile = File.createTempFile("ucr-deploy", "json");
//Files.copy(appDefinitionFile.toPath(), tmpFile.toPath(), REPLACE_EXISTING);

Path path = Paths.get(appDefinitionFile.getAbsolutePath());
Charset charset = StandardCharsets.UTF_8;
Expand All @@ -54,17 +54,17 @@ public void execute() throws MojoExecutionException {
content = content.replaceAll("<FILENAME>", file.getName());
content = content.replaceAll("<NEXUS_URL>", nexusUrl);

FileOutputStream fooStream = new FileOutputStream(appDefinitionFile, false);
FileOutputStream fooStream = new FileOutputStream(tmpFile, false);
fooStream.write(content.getBytes());
fooStream.close();

getLog().info(tmpPath.toString());
getLog().info("TempFile: " + tmpFile.toPath().toString());

HttpPut put = new HttpPut(buildDcosUrl(marathonConfigurationJson.get("id"), marathonConfigurationJson) + "?force=true'");
put.setHeader("Authorization", "token=" + DcosPluginHelper.readToken(dcosTokenFile));
put.setHeader("Content-Type", "application/json");

put.setEntity(new FileEntity(appDefinitionFile));
put.setEntity(new FileEntity(tmpFile));

CloseableHttpResponse response = client.execute(put);
getLog().info("Response from DC/OS [" + response.getStatusLine().getStatusCode() + "] " + IOUtils.toString(response.getEntity().getContent(), "UTF-8"));
Expand All @@ -80,9 +80,9 @@ public void execute() throws MojoExecutionException {
}
}
// clean up after deployment
if (tmpPath != null && tmpPath.toFile().exists()) {
if (tmpFile != null && tmpFile.exists()) {
try {
Files.delete(tmpPath);
Files.delete(tmpFile.toPath());
} catch (IOException e) {
getLog().warn("Unable to delete temporary app definition", e);
}
Expand Down

0 comments on commit d7c0555

Please sign in to comment.