Skip to content

Commit

Permalink
CLC v1.7.1. Maven v0.9
Browse files Browse the repository at this point in the history
Publish clc with custom settings feature (and uri-reference).
Maven plugin cleanup.
Use latest CLC in plugin.
  • Loading branch information
zapov committed May 26, 2016
1 parent 4796286 commit 6ece3c2
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ public class Context implements Closeable {
private final Map<String, String> parameters = new HashMap<String, String>();
private final Map<String, Object> cache = new HashMap<String, Object>();

private PrintStream console = AnsiConsole.out();
private PrintStream console;

private boolean withLog;
private boolean noPrompt;
private boolean withColor = true;

public Context() {
this(AnsiConsole.out());
}

protected Context(PrintStream console) {
this.console = console;
}

public void put(final CompileParameter parameter, final String value) {
if (parameter instanceof DisablePrompt) {
noPrompt = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ private static void showHelpAndExit(final Context context, final boolean headers
context.show("\tproperties=development.props download");
}

private static final Properties versionInfo = new Properties();

private static String getVersionInfo(final String section) {
try {
final Enumeration<URL> resources = Main.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package com.dslplatform.compiler.client;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.net.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -64,7 +59,7 @@ public static String read(final InputStream stream) throws IOException {
while ((len = stream.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
return new String(baos.toByteArray(), "UTF-8");
return baos.toString("UTF-8");
}

public static Either<String> readFile(final File file) {
Expand Down Expand Up @@ -201,11 +196,7 @@ public static synchronized Either<Document> readXml(final InputStream stream) {
final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
return Either.success(dBuilder.parse(stream));
} catch (IOException ex) {
return Either.fail(ex);
} catch (ParserConfigurationException ex) {
return Either.fail(ex);
} catch (SAXException ex) {
} catch (Exception ex) {
return Either.fail(ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.IOException;
import java.util.*;

public abstract class DslJson {
public abstract class JSON {

private static Object deserializeObject(final JsonReader reader) throws IOException {
switch (reader.last()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dslplatform.compiler.client.parameters;

import com.dslplatform.compiler.client.*;
import com.dslplatform.compiler.client.json.DslJson;
import com.dslplatform.compiler.client.json.JSON;
import org.w3c.dom.*;

import java.io.*;
Expand Down Expand Up @@ -278,7 +278,7 @@ private Either<ParseResult> parseTokens(final Socket socket, final String dsl) t
os.write(buf, 0, read);
}
os.flush();
return Either.success(new ParseResult(DslJson.readMap(os.getBuffer(), os.size())));
return Either.success(new ParseResult(JSON.readMap(os.getBuffer(), os.size())));
} catch (IOException e) {
return Either.fail(e.getMessage());
}
Expand Down Expand Up @@ -698,6 +698,7 @@ public String getShortDescription() {
public String getDetailedDescription() {
return "DSL Platform compiler.\n" +
"Requires .NET/Mono to run.\n" +
"It is available for download at: https://compiler.dsl-platform.com:8443/platform/download/dsl-compiler.zip\n" +
"\n" +
"Example:\n" +
"\tcompiler\n" +
Expand Down
6 changes: 3 additions & 3 deletions MavenPlugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<groupId>com.dslplatform</groupId>
<artifactId>dsl-platform-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>0.8</version>
<name>dsl-platform-maven-plugin</name>
<version>0.9</version>
<name>DSL Platform - Maven plugin</name>
<url>https://github.com/ngs-doo/dsl-compiler-client</url>
<description>A Maven plugin for interaction with DSL Platform command line client API (https://dsl-platform.com)</description>

Expand Down Expand Up @@ -63,7 +63,7 @@
<dependency>
<groupId>com.dslplatform</groupId>
<artifactId>dsl-clc</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>

<dependency>
Expand Down
58 changes: 28 additions & 30 deletions MavenPlugin/src/main/java/com/dslplatform/mojo/DslPlatformMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import com.dslplatform.compiler.client.CompileParameter;
import com.dslplatform.compiler.client.Main;
import com.dslplatform.compiler.client.parameters.*;
import com.dslplatform.mojo.context.MojoContext;
import com.dslplatform.mojo.utils.Utils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand All @@ -13,11 +10,8 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.File;
import java.util.List;
import java.util.Properties;

@Mojo(name = DslPlatformMojo.GOAL)
public class DslPlatformMojo extends AbstractMojo {
Expand All @@ -30,9 +24,10 @@ public class DslPlatformMojo extends AbstractMojo {
private MavenProject project;

@Parameter(required = true)
private Properties properties;
private String properties;

private String propertiesAbsolutePath;
@Parameter(property = "plugins", defaultValue = ".")
private String plugins;

public MavenProject getProject() {
return project;
Expand All @@ -42,30 +37,20 @@ public void setProject(MavenProject project) {
this.project = project;
}

public Properties getProperties() {
public String getProperties() {
return properties;
}

public void setProperties(String path) {
propertiesAbsolutePath = Utils.resourceAbsolutePath(path);
getLog().info("Setting properties from file: " + propertiesAbsolutePath);
try {
if (propertiesAbsolutePath != null) {
properties = new Properties();
properties.load(new FileInputStream(propertiesAbsolutePath));

}
} catch (IOException e) {
this.properties = null;
}
public void setProperties(String value) {
this.properties = value;
}

public String getPropertiesAbsolutePath() {
return propertiesAbsolutePath;
public void setPlugins(String value) {
this.plugins = value;
}

public void setPropertiesAbsolutePath(String propertiesAbsolutePath) {
this.propertiesAbsolutePath = propertiesAbsolutePath;
public String getPlugins() {
return plugins;
}

public MojoContext getContext() {
Expand All @@ -74,13 +59,26 @@ public MojoContext getContext() {

public void execute() throws MojoExecutionException, MojoFailureException {

if (this.properties == null) {
throw new MojoExecutionException("The given properties file not found: " + propertiesAbsolutePath);
if (this.properties == null || this.properties.length() == 0) {
throw new MojoExecutionException("The properties file not specified");
}
String path = Utils.resourceAbsolutePath(this.properties);
if (path == null) {
throw new MojoExecutionException("Specified properties file not found: " + properties);
}
this.context.put("properties", path);

this.context.with(new PropertiesFile(new ArrayList<CompileParameter>()), propertiesAbsolutePath);
if (plugins == null || plugins.length() == 0) {
plugins = ".";
}
File pluginsFile = new File(plugins);
if (!pluginsFile.exists()) {
throw new MojoExecutionException("Specified plugins path not found: " + pluginsFile.getAbsolutePath());
} else if (!pluginsFile.isDirectory()) {
throw new MojoExecutionException("Please specify path to directory, not a specific file: " + pluginsFile.getAbsolutePath());
}

List<CompileParameter> params = Main.initializeParameters(context, ".");
List<CompileParameter> params = Main.initializeParameters(context, pluginsFile.getAbsolutePath());

if (!Main.processContext(context, params)) {
throw new MojoExecutionException(context.errorLog.toString());
Expand Down
Loading

0 comments on commit 6ece3c2

Please sign in to comment.