Installing Maven on Linux, compile Apache Eagle project

Copyright: copyright reserved by the authors, are reproduced in any form, please indicate the source. https://blog.csdn.net/xiaokui9/article/details/82424947

Compile debugging process took several days, should be psychologically prepared, compiled once could take several hours, especially plus -X parameter debug output will be slower, with no hurry yet, each compilation problems, tune after compiling had to start again from scratch, or may be a compilation of all the other different error. The -e parameter is also OK, it can output full error message will long point short compile time. Later it will be faster, but at least have half an hour to start.

Also due to the build process to download a lot of files, I often get stuck in a download file that, when I was stuck in a local general file downloads, more than 10 minutes, I crtl + c, then began again. Then the whole process of downloading the file and re-start compiling interrupt problem, I could at least interrupted dozens of times.

Error might want to see the process directly see the final information.

 

table of Contents

1, maven installation

2, install git

3, and the installation nodejs npm

4, the end of line test code file newline

5, compiled eagle

6, the compilation process error


 

1, maven installation

(1) from http://maven.apache.org/download.cgi download the latest installation package apache-maven-3.5.4-bin.tar.gz.

You need to make sure the machine has been installed and configured JDK environment variables prior to installation.

(2) extracting in / opt directory

$ Tar -zxvf apache-maven-3.5.4-bin.tar.gz

$ vim /etc/profile

(3) modify the environment variable, add the following lines in the / etc / profile in

export MAVEN_HOME=/opt/apache-maven-3.5.4-bin

export PATH=${PATH}:${MAVEN_HOME}/bin

(4) then the environment variables to take effect

$ source /etc/profile

(5) the last run mvn -versionto verify whether the installation was successful maven, if successful installation will print the following

(6) establish maven repository

Reference: https://www.cnblogs.com/-mrl/p/8952558.html

a) create a folder, the path is assumed: / usr / local / maven_repository.

b) Open /conf/setting.xml file maven directory, set the path to our warehouse:

 

<!-- localRepository  
  | The path to the local repository maven will use to store artifacts.  
  |  
  | Default: ${user.home}/.m2/repository  
 <localRepository>/path/to/local/repo</localRepository>  
 -->  
 <localRepository>/usr/local/maven_repository</localRepository> 

 

c) a terminal running the command packet from the common central maven local repository to download the file:

  mvn help:system

d) there are no errors, then open the / usr / local / maven_repository will find a lot more files.

 

2, install git

(1) installing its dependencies
yum curl the install the gettext-devel expat-devel-devel OpenSSL-devel zlib-devel Perl-GCC-MakeMaker the ExtUtils
(2) to download the source code and extracting git
wget https://www.kernel.org/pub /software/scm/git/git-2.9.5.tar.gz
decompression Git-2.9.5.tar.gz zxvf the tar
CD Git-2.9.5
(. 3) compiled and installed 
the make prefix = / usr / local / Git All
the make = prefix / usr / local / git install
(4) View git
whereis git
git --version
(5) configuration environment variable
vim / etc / profile
Join export PATH = $ PATH: / usr / local / git / bin
valid configuration file source / etc / profile

 

3, and the installation nodejs npm

Curl -sl https://rpm.nodesource.com/setup_6.x $ | bash -  
$ yum install -y nodejs
command: node -v prints the version number if it is installed successfully.

Then update npm (at this time npm command has been with the installation process nodejs to install, update about the latest version)
$ @ Latest npm npm install -g
command: npm -v prints the version number successfully installed.

If this command is a problem, you can install the following ways npm

$ wget http://npmjs.org/install.sh  
$ chmod +x ./install.sh  
$ ./install.sh

Updates node version is:

    Npm to clear the cache: npm cache clean -f
    then install the module n: npm install -gn
    upgrade to the latest stable version node.js: n stable

See also: https://blog.csdn.net/qq_33242126/article/details/78505281

The following command will be executed under the eagle-server \ src \ main \ webapp \ app directory, if you do not succeed, will compile error, see the eagle-server \ ui-build.sh file command

$ npm install
$ npm run build

 

4, the end of line test code file newline

Because I was copied from the windows over, line breaks using the windows \ r \ n, need to be replaced \ n.

(1) using the "cat -A [Filename]" view, as shown, as seen in the form of a Windows newline, \ R & lt below the corresponding symbol ^ M, \ $ n-corresponding symbol.

(2) Installation dos2unix

$ yum install -y dos2unix

(3) the full catalog file replacement

find /opt/code/eagle-master/ -name "*" | xargs dos2unix

Reference: https://blog.csdn.net/leedaning/article/details/53024290

Or command

find . -type f -exec dos2unix {} \;

Reference https://blog.csdn.net/u011537073/article/details/50603316

 

5, compiled eagle

(1) The eagle-master.zip copied to the / opt directory, unzip and

$ unzip eagle-master.zip

(2) adjust the memory used

$ export MAVEN_OPTS='-Xmx1536M -Xms512M -XX:MaxPermSize=256m'

I tried -Xmx1024M, or being given enough memory, 1536M on it. Reference: https: //www.cnblogs.com/shengs/p/4655743.html

(3) into the lower opt / / eagle-master directory, compile command:

$ mvn -Dmaven.test.skip=true clean package -X

-X is used to print the debug log information, you do not want to see debug, can be changed to -e, you view the error message.

mvn command can refer to a post before.

 

6, the compilation process error

(1)Could not transfer artifact org.apache.maven.plugins:maven-remote-resources-plugin:pom:1.5 from/to central

[ERROR] Plugin org.apache.maven.plugins:maven-remote-resources-plugin:1.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-remote-resources-plugin:jar:1.5: Could not transfer artifact org.apache.maven.plugins:maven-remote-resources-plugin:pom:1.5 from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version -> [Help 1]

org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-remote-resources-plugin:1.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-remote-resources-plugin:jar:1.5

Solution: Referring to 1, like the rear (6) c) download central repository

 

(2) DEBUG exception of the information output checkstyle

[DEBUG] Keep looking, ignoring exception

java.lang.ClassNotFoundException: com.puppycrawl.tools.checkstyle.checks.annotation.CommentsIndentationCheck

[DEBUG] Keep looking, ignoring exception

java.lang.ClassNotFoundException: com.puppycrawl.tools.checkstyle.checks.header.CommentsIndentationCheck

[DEBUG] Keep looking, ignoring exception

java.lang.ClassNotFoundException: com.puppycrawl.tools.checkstyle.checks.whitespace.CommentsIndentationCheck

Each time plus -X compiler will checkstyle a bunch of mistakes, ignored like.

 

(3)报错:java.lang.OutOfMemoryError:Java heap space

Solution: Before compiling command, perform

$ export MAVEN_OPTS='-Xmx1536M -Xms512M -XX:MaxPermSize=256m'

https://cwiki.apache.org//confluence/display/MAVEN/OutOfMemoryError

https://www.cnblogs.com/shengs/p/4655743.html

1, the reason

Since the JVM is wrong with the server is not enough and thrown, JVM will automatically set the value of the Heap size at startup, the initial space (ie -Xms) is the physical memory of 1/64, the largest space (-Xmx) of physical memory 1/4. It is possible to modify the JVM -Xmn -Xms -Xmx and other options depending on your situation.

2, memory size

The maximum Heap Size should not exceed 80% of the available physical memory, generally want -Xms and -Xmx option is set to the same, and -Xmn for the -Xmx value of 1/4. Heap size of -Xms -Xmn settings do not exceed the size of physical memory.

 

(4)GET request of: ***.jar from apache.snapshots failed: Read timed out

[ERROR] Failed to execute goal on project eagle-server: Could not resolve dependencies for project org.apache.eagle:eagle-server:jar:0.5.0-SNAPSHOT: Could not transfer artifact org.apache.eagle:eagle-hadoop-queue:jar:0.5.0-20171123.001558-270 from/to apache.snapshots (http://repository.apache.org/snapshots): GET request of: org/apache/eagle/eagle-hadoop-queue/0.5.0-SNAPSHOT/eagle-hadoop-queue-0.5.0-20171123.001558-270.jar from apache.snapshots failed: Read timed out -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project eagle-server: Could not resolve dependencies for project org.apache.eagle:eagle-server:jar:0.5.0-SNAPSHOT: Could not transfer artifact org.apache.eagle:eagle-hadoop-queue:jar:0.5.0-20171123.001558-270 from/to apache.snapshots (http://repository.apache.org/snapshots): GET request of: org/apache/eagle/eagle-hadoop-queue/0.5.0-SNAPSHOT/eagle-hadoop-queue-0.5.0-20171123.001558-270.jar from apache.snapshots failed

Workaround: Manually go http://repository.apache.org/snapshots/org/apache/eagle/eagle-hadoop-queue/0.5.0-SNAPSHOT/ download eagle-hadoop-queue-0.5.0-20171123.001558-270. jar and eagle-hadoop-queue-0.5.0-20171123.001558-270.jar.sha1 copied to the corresponding main warehouse org / apache / eagle / eagle- hadoop-queue / 0.5.0-SNAPSHOT / directory can.

 

(5)exec (exec-ui-install) on project eagle-server: Command execution failed.: Process exited with an error

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (exec-ui-install) on project eagle-server: Command execution failed.: Process exited with an error: 2 (Exit value: 2) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (exec-ui-install) on project eagle-server: Command execution failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
……
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed.
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:276)
   ……
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 2)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
……
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[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
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :eagle-server

Solution: Find the configuration file content on exec (exec-ui-install), and then found ui-build.sh file, I found that there are checks git, npm, nodejs content, own the inside of the command after the installation of all after the successful implementation of his party, the problem is solved.

echo "Environment Check..."
# Pre-build check
if [ -z "$(command -v git)" ]
then
	echo "git not installed!"
	exit 1
fi
if [ -z "$(command -v npm)" ]
then
	echo "npm not installed!"
	exit 1
fi
echo "Environment Check...Pass"

# npm install
cd src/main/webapp/app
echo "npm install..."
npm install

echo "building..."
npm run build

 

Guess you like

Origin blog.csdn.net/xiaokui9/article/details/82424947