Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fomkin committed Dec 21, 2012
0 parents commit 1c44689
Show file tree
Hide file tree
Showing 8 changed files with 595 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea
*.ipr
*.iws
*.iml
target
114 changes: 114 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.yelbota.plugins</groupId>
<artifactId>haxe-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1.0-SNAPSHOT</version>

<name>Maven plugin to build haXe projects</name>

<developers>
<developer>
<name>Aleksey Fomkin</name>
<email>[email protected]</email>
</developer>
</developers>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>

<build>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
<configuration>
<header>${basedir}/src/etc/resources/license-header.txt</header>
<failIfMissing>true</failIfMissing>
<strictCheck>true</strictCheck>
<aggregate>true</aggregate>
<includes>
<include>src/main/java/**</include>
<include>src/test/java/**</include>
</includes>
</configuration>
<executions>
<execution>
<id>license-update</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.1</version>
<configuration>
<goalPrefix>haxe</goalPrefix>
</configuration>
<executions>
<execution>
<goals>
<goal>addPluginArtifactMetadata</goal>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.yelbota.plugins</groupId>
<artifactId>native-dependency-maven-plugin-base</artifactId>
<version>1.1</version>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>2.0-alpha-1</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
<repository>
<!-- I know, I know! -->
<id>yelbota-dropbox-repository</id>
<url>file:///Users/yelbota/Dropbox/Public/maven</url>
</repository>
</distributionManagement>

<scm>
<url>https://github.com/yelbota/adt-maven-plugin</url>
<developerConnection>scm:git:github.com/yelbota/adt-maven-plugin.git</developerConnection>
<connection>scm:git:github.com/yelbota/adt-maven-plugin.git</connection>
</scm>

</project>
13 changes: 13 additions & 0 deletions src/etc/resources/license-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (C) 2012 https://github.com/yelbota/haxe-maven-plugin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
62 changes: 62 additions & 0 deletions src/main/java/com/yelbota/plugins/haxe/AbstractHaxeMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (C) 2012 https://github.com/yelbota/haxe-maven-plugin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yelbota.plugins.haxe;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.repository.RepositorySystem;

import java.io.File;
import java.util.List;

abstract public class AbstractHaxeMojo extends AbstractMojo {

/**
* @component
* @readonly
*/
protected RepositorySystem repositorySystem;

/**
* @parameter property="plugin.artifacts"
* @readonly
* @required
*/
public List<Artifact> pluginArtifacts;

/**
* @parameter property="localRepository"
* @required
* @readonly
*/

protected ArtifactRepository localRepository;
/**
* @parameter property="project.remoteArtifactRepositories"
* @required
* @readonly
*/
protected List<ArtifactRepository> remoteRepositories;

/**
* Location of the file.
*
* @parameter property="project.build.directory"
* @required
*/
protected File outputDirectory;
}
99 changes: 99 additions & 0 deletions src/main/java/com/yelbota/plugins/haxe/CommandHaxeMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* Copyright (C) 2012 https://github.com/yelbota/haxe-maven-plugin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yelbota.plugins.haxe;

import com.yelbota.plugins.haxe.utils.CleanStream;
import com.yelbota.plugins.nd.DependencyHelper;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

/**
* @goal command
* @phase package
* @threadSafe
*/
public class CommandHaxeMojo extends UnpackHaxeMojo {

/**
* Custom adt arguments
* @parameter property="arguments"
*/
protected String arguments;

@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
super.execute();
prepareArguments();

ArrayList<String> finalArgs = new ArrayList<String>();
String executableName = "haxe";

if (haxeArtifact.getClassifier() == DependencyHelper.OS_CLASSIFIER_WINDOWS)
executableName += ".exe";

File adtFile = FileUtils.resolveFile(unpackDirectory, executableName);
finalArgs.add(adtFile.getAbsolutePath());

for (String s: StringUtils.split(arguments, " "))
finalArgs.add(s);

execute(finalArgs.toArray(new String[]{}));
}

protected void prepareArguments() throws MojoFailureException
{
// Override this method for arguments modification.
}

public void execute(String[] args) throws MojoFailureException
{
try {

getLog().debug(StringUtils.join(args, " "));
Process process = Runtime.getRuntime().exec(args);

CleanStream cleanError = new CleanStream(process.getErrorStream(),
getLog(), CleanStream.CleanStreamType.ERROR);

CleanStream cleanOutput = new CleanStream(process.getInputStream(),
getLog(), CleanStream.CleanStreamType.INFO);

cleanError.start();
cleanOutput.start();

int code = process.waitFor();

if (code > 0) {
throw new MojoFailureException("haxe fails with return code #" + code );
}

} catch (IOException e) {

throw new MojoFailureException("Cant execute haxe", e);

} catch (InterruptedException e) {

throw new MojoFailureException("Process was interrupted", e);
}
}
}
Loading

0 comments on commit 1c44689

Please sign in to comment.