Commit 586eb8c2 authored by Tommy Olofsson's avatar Tommy Olofsson
Browse files

Made the maven plugin better.

parent 8c3bf614
......@@ -29,6 +29,12 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>se.lth.control</groupId>
<artifactId>labcomm_compiler</artifactId>
......
# labcomm-compiler-plugin
Compiles labcomm files during the maven build lifecycle.
## Example
To use the plugin to compile the file `my_types.lc` put the following
in your maven build file (pom.xml). You can then use the types as
`import labcomm_gen.sample` where `sample` is the name of the
sample(s) in the my_types.lc.
```xml
<project>
<!-- ... -->
<dependencies>
<!-- ... -->
<!-- labcomm lib -->
<dependency>
<groupId>se.lth.control</groupId>
<artifactId>labcomm</artifactId>
<version>2014.3.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- ... -->
<plugin>
<!-- labcomm compiler -->
<groupId>se.lth.control</groupId>
<artifactId>labcomm-compiler-plugin</artifactId>
<version>2014.3.0-SNAPSHOT</version>
<configuration>
<lc>path/to/my_types.lc</lc>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>genjava</goal>
</goals>
</execution>
</executions>
</plugin>
<build>
<plugins>
<repositories>
<repository>
<!-- source of dep/plugin -->
<id>CSLTH</id>
<name>CS LTH maven repo</name>
<url>http://maven.cs.lth.se/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
```
......@@ -3,6 +3,7 @@ package se.lth.control;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.project.MavenProject;
import se.lth.control.labcomm2014.compiler.LabComm;
/**
......@@ -12,26 +13,31 @@ import se.lth.control.labcomm2014.compiler.LabComm;
public class App extends AbstractMojo {
/**
* @parameter default-value="notafile.lc"
* @parameter default-value="path_to_file.lc"
*/
private String lc;
/**
* @parameter default-value="/tmp"
* @parameter default-value="${project.build.directory}/labcomm_gen"
*/
private String dir;
/**
* @parameter default-value="generated_sources"
* @parameter default-value="labcomm_gen"
*/
private String pkg;
/**
* @parameter default-value="${project}"
*/
private MavenProject project;
public void execute() throws MojoExecutionException {
getLog().info("Does not do anything!");
String[] args = new String[3];
args[0] = "--java=" + dir;
args[1] = "--javapackage=" + pkg;
args[2] = lc;
LabComm.main(args);
project.addCompileSourceRoot(dir);
LabComm.main(new String[] {
"--java=" + dir,
"--javapackage=" + pkg,
lc,
});
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment