tools4j / unix4j

An implementation of Unix command line tools in Java.
unix4j.org
MIT License
236 stars 43 forks source link

How to build and run the project #46

Closed gongzelong0718 closed 6 years ago

gongzelong0718 commented 6 years ago

I clone the project. Could anyone tell me how to build and run the project? For example, I want to use ls command line.

Plus, I imported the project using IDEA for both /unix4j/unix4j-core and /unix4j. But IDE could not resolve LsArguments. Anyone know why?

screenshot from 2018-01-15 19 48 30 screenshot from 2018-01-15 19 48 56

terzerm commented 6 years ago

You have to build it with maven. The reason that some classes are not found is that they are generated during the build.

Run “mvn clean install’ from command line or use import pom in Intellij and then build from there.

Regards, Marco

gongzelong0718 commented 6 years ago

Sorry, I run mvn clean install in the directory /home/zelongg/Code/unix4j. It shows in the Terminal:

[INFO] Reactor Summary:
[INFO] 
[INFO] unix4j ............................................. SUCCESS [  1.329 s]
[INFO] unix4j-tools ....................................... SUCCESS [  9.334 s]
[INFO] unix4j-core ........................................ SUCCESS [  0.060 s]
[INFO] unix4j-base ........................................ SUCCESS [  9.167 s]
[INFO] unix4j-command ..................................... SUCCESS [ 25.956 s]
[INFO] unix4j-perf ........................................ SUCCESS [  7.823 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.983 s
[INFO] Finished at: 2018-01-16T11:20:26+08:00
[INFO] Final Memory: 33M/557M
[INFO] ------------------------------------------------------------------------

screenshot from 2018-01-16 11 26 05

Could you tell me what I should do next?

I also tried build project, but it fails

Information:Using javac 1.8.0_131 to compile java sources
Information:java: Errors occurred while compiling module 'unix4j-command'
Information:18-1-16 上午11:23 - Compilation completed with 100 errors and 29 warnings in 6s 389ms
gongzelong0718 commented 6 years ago

use import pom in Intellij and then build from there What directory should I choose when I want to open the pom.xml, /unix4j/unix4j-core or /unix4j?

I mainly want to see how to implement ls command line.

Oh, I close the 2 existing projects. And open the pom.xml in /unix4j, and then select build -> build project.

It shows in Message:

Information:Using javac 1.8.0_131 to compile java sources
Information:Modules "unix4j-command", "unix4j", "unix4j-perf" were fully rebuilt due to project configuration/dependencies changes
Information:18-1-16 上午11:30 - Compilation completed successfully with 19 warnings in 7s 244ms

It seems that it build successfully. How amazing!

gongzelong0718 commented 6 years ago

After I build successfully using your second way. I tried to use ls command line. I notice that in the wiki, it says ExampleTest.java does that. According to this file unix4j-examples/README.txt

So I run and got this:

elongg@zelongg:~/Code/unix4j/unix4j-examples$ mvn clean install
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for org.unix4j:unix4j-examples:jar:0.4-SNAPSHOT
[WARNING] 'profiles.profile[snapshots].dependencies.dependency.version' for org.unix4j:unix4j-command:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 53, column 30
[WARNING] 'profiles.profile[prod].dependencies.dependency.version' for org.unix4j:unix4j-command:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 103, column 30
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building unix4j-examples 0.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.unix4j:unix4j-command:jar:0.4-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.270 s
[INFO] Finished at: 2018-01-16T11:37:47+08:00
[INFO] Final Memory: 8M/240M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project unix4j-examples: Could not resolve dependencies for project org.unix4j:unix4j-examples:jar:0.4-SNAPSHOT: Could not find artifact org.unix4j:unix4j-command:jar:0.4-SNAPSHOT -> [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/DependencyResolutionException
zelongg@zelongg:~/Code/unix4j/unix4j-examples$ 
gongzelong0718 commented 6 years ago

Should I check the document https://www.jetbrains.com/help/idea/maven.html?

terzerm commented 6 years ago

Sorry the pom was pointing to the wrong version.

Update to newest version (git pull) then try again. You may need to rebuild unix4j first to rebuild the snapshot version before you build the examples project.

Regards, Marco

gongzelong0718 commented 6 years ago

Thanks, Marco, it works.

esults :

Tests run: 23, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ unix4j-perf ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /home/zelongg/Code/unix4j/unix4j-perf/target/unix4j-perf-0.5-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ unix4j-perf ---
[INFO] Installing /home/zelongg/Code/unix4j/unix4j-perf/target/unix4j-perf-0.5-SNAPSHOT.jar to /home/zelongg/.m2/repository/org/unix4j/unix4j-perf/0.5-SNAPSHOT/unix4j-perf-0.5-SNAPSHOT.jar
[INFO] Installing /home/zelongg/Code/unix4j/unix4j-perf/pom.xml to /home/zelongg/.m2/repository/org/unix4j/unix4j-perf/0.5-SNAPSHOT/unix4j-perf-0.5-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] unix4j ............................................. SUCCESS [  1.900 s]
[INFO] unix4j-tools ....................................... SUCCESS [ 10.705 s]
[INFO] unix4j-core ........................................ SUCCESS [  0.065 s]
[INFO] unix4j-base ........................................ SUCCESS [ 12.151 s]
[INFO] unix4j-command ..................................... SUCCESS [ 21.150 s]
[INFO] unix4j-perf ........................................ SUCCESS [  9.179 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 55.408 s
[INFO] Finished at: 2018-01-30T10:42:06+08:00
[INFO] Final Memory: 34M/641M
[INFO] ------------------------------------------------------------------------

For the record, I wrote down the way of building:

zelongg@zelongg:~/Code/unix4j$ pwd
/home/zelongg/Code/unix4j
zelongg@zelongg:~/Code/unix4j$ mvn clean install