Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions maven-jnaerator-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>3.0-alpha-2</version>
<artifactId>maven-core</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.sonatype.plexus.build.incremental.BuildContext;

import com.ochafik.lang.jnaerator.*;

Expand Down Expand Up @@ -73,6 +74,16 @@ public class JNAeratorMojo
*/
private MavenProject project;


/**
* @component
* @required
* @readonly
*
*/
private BuildContext buildContext;


static File canonizeDir(File f) throws IOException {
if (!f.exists())
f.mkdirs();
Expand All @@ -90,16 +101,16 @@ public void execute()
List<String> args = new ArrayList<String>();

args.add(config.getAbsolutePath());

// Override settings from config file :
args.add("-mode");
args.add(JNAeratorConfig.OutputMode.Directory.name());
args.add("-f");
args.add("-o");

File javaDir = canonizeDir(javaOutputDirectory);
args.add(javaDir.toString());

project.addCompileSourceRoot(javaDir.toString());

if (generateScala) {
Expand All @@ -108,6 +119,13 @@ public void execute()
}

com.ochafik.lang.jnaerator.JNAerator.main(args.toArray(new String[0]));

//attempt to have eclipse adding the generated directory to it the source path
if (this.buildContext != null) {
this.buildContext.refresh(javaDir);
getLog().info( "Refreshing " + javaDir );
}

}
catch (Exception e )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
<runOnConfiguration>true</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>