# Maven build plugin failed with official document

**URL:** <https://discuss.elastic.co/t/maven-build-plugin-failed-with-official-document/108497>\
**Category:** Elasticsearch\
**Created:** [November 21, 2017, 3:39am UTC](https://discuss.elastic.co/t/maven-build-plugin-failed-with-official-document/108497 "2017-11-21T03:39:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BrickXu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brickxu/32/15462_2.png) [@BrickXu](https://discuss.elastic.co/u/BrickXu)\
**Post date:** [November 21, 2017, 3:39am UTC](https://discuss.elastic.co/t/maven-build-plugin-failed-with-official-document/108497/1 "2017-11-21T03:39:38Z")

</div>

Refs to [https://www.elastic.co/guide/en/elasticsearch/plugins/2.4/plugin-authors.html](https://www.elastic.co/guide/en/elasticsearch/plugins/2.4/plugin-authors.html)

I build my project with maven, and the pom.xml is the following:

```
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.github.brickxu</groupId>
    <artifactId>audit</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.elasticsearch.plugin</groupId>
        <artifactId>plugins</artifactId>
        <version>2.4.6</version>
    </parent>

    <properties>
        <elasticsearch.version>2.4.6</elasticsearch.version>
        <elasticsearch.plugin.classname>com.github.birckxu.audit.AuditPlugin</elasticsearch.plugin.classname>
        <elasticsearch.plugin.name>elasticsearch-audit</elasticsearch.plugin.name>
        <elasticsearch.plugin.site>false</elasticsearch.plugin.site>
        <elasticsearch.plugin.jvm>true</elasticsearch.plugin.jvm>
        <elasticsearch.assembly.descriptor>src/main/assembly/assembly.xml</elasticsearch.assembly.descriptor>
        <skip.unit.tests>true</skip.unit.tests>
        <skip.integ.tests>true</skip.integ.tests>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

```

And I run mvn package with this pom.xml, it shows some error message:

```
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building audit 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-versions) @ audit ---
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven-version) @ audit ---
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:display-info (print-versions) @ audit ---
[INFO] Maven Version: 3.3.9
[INFO] JDK Version: 1.8.0_151 normalized as: 1.8.0-151
[INFO] OS Info: Arch: x86_64 Family: mac Name: mac os x Version: 10.12.6
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-java-home-is-set) @ audit ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireEnvironmentVariable failed with message:
"JAVA_HOME must be set and point to the jdk to run the tests"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.944 s
[INFO] Finished at: 2017-11-21T11:34:00+08:00
[INFO] Final Memory: 20M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-java-home-is-set) on project audit: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

```

but I already set $JAVA\_HOME before.

```
➜ ~ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
➜ ~ which java
/usr/bin/java
➜ ~ which javac
/usr/bin/javac

```

How to resolve this issue ? I found another same [issue](https://discuss.elastic.co/t/elasticsearch-2-3-5-maven-build-error-with-enforce-plugin-java-home/67188/2) here but there is no answer.

---

<div class="post-metadata">

**Author:** ![BrickXu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brickxu/32/15462_2.png) [@BrickXu](https://discuss.elastic.co/u/BrickXu)\
**Post date:** [November 21, 2017, 4:25am UTC](https://discuss.elastic.co/t/maven-build-plugin-failed-with-official-document/108497/2 "2017-11-21T04:25:18Z")

</div>

Find the answer, Idea does not read the env variable correctly, use `launchctl setenv JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home` could fix it.

Please close this issue. Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 19, 2017, 4:25am UTC](https://discuss.elastic.co/t/maven-build-plugin-failed-with-official-document/108497/3 "2017-12-19T04:25:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
