Skip to content
Snippets Groups Projects
Commit 586eb8c2 authored by Tommy Olofsson's avatar Tommy Olofsson
Browse files

Made the maven plugin better.

parent 8c3bf614
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,12 @@ ...@@ -29,6 +29,12 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
<dependency> <dependency>
<groupId>se.lth.control</groupId> <groupId>se.lth.control</groupId>
<artifactId>labcomm_compiler</artifactId> <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; ...@@ -3,6 +3,7 @@ package se.lth.control;
import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.project.MavenProject;
import se.lth.control.labcomm2014.compiler.LabComm; import se.lth.control.labcomm2014.compiler.LabComm;
/** /**
...@@ -12,26 +13,31 @@ import se.lth.control.labcomm2014.compiler.LabComm; ...@@ -12,26 +13,31 @@ import se.lth.control.labcomm2014.compiler.LabComm;
public class App extends AbstractMojo { public class App extends AbstractMojo {
/** /**
* @parameter default-value="notafile.lc" * @parameter default-value="path_to_file.lc"
*/ */
private String lc; private String lc;
/** /**
* @parameter default-value="/tmp" * @parameter default-value="${project.build.directory}/labcomm_gen"
*/ */
private String dir; private String dir;
/** /**
* @parameter default-value="generated_sources" * @parameter default-value="labcomm_gen"
*/ */
private String pkg; private String pkg;
/**
* @parameter default-value="${project}"
*/
private MavenProject project;
public void execute() throws MojoExecutionException { public void execute() throws MojoExecutionException {
getLog().info("Does not do anything!"); project.addCompileSourceRoot(dir);
String[] args = new String[3]; LabComm.main(new String[] {
args[0] = "--java=" + dir; "--java=" + dir,
args[1] = "--javapackage=" + pkg; "--javapackage=" + pkg,
args[2] = lc; lc,
LabComm.main(args); });
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment