Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
551 views
in Technique[技术] by (71.8m points)

java - Idea IntelliJ. how creating maven project. what about pom.xml and .iml files

i just started with java, and created a project. its maven project (i hadn't use maven yet)

so my project have two modules A and B. and B depends on A, and A depends on some from remote maven repo. and B also depends on some remote repo. its works fine in Idea IntelliJ and build jars fine.

but afaik .iml files are Idea IntelliJ specific. and pom.xml is maven specific. and when i inspect files why all depedecy of project is written in .iml files and .idea dir instead of pom.xml(s)

if you want to see the real world source then here it is but its alpha project for learning java deeply. and when i try to build project on travis-ci.org it unable to resolve dependencies of project

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Meghraj,

I have forked your WebTrimmer repo here : https://github.com/ajorpheus/WebTrimmer and fixed a couple of issues which were preventing a successful build:

  1. The travisci fails because you have three jars in the lib folder which are not available to the CI since it's doing a maven build.

    The fix was to remove those three jars and introduce corresponding maven dependencies as in this commit.

  2. While adding the maven dependencies an exclusion was needed as noted here : The following artifacts could not be resolved: javax.jms:jms:jar:1.1

  3. The WebTrimmerUI depends on the classes in it's sibling module WebTrimmerEngine, therefore a corresponding dependency is needed.

I have converted the project into a pure maven project which is IDE-agnostic. With the above changes, I can build the project from command line and expect that the travisci should be able to as well.

Regarding the question about why the dependencies are duplicated in .iml --- That's not the reason the CI job fails. The dependencies in that file are a snapshot of the dependencies in the pom.xml. This snapshot is updated when the maven project is re-imported manually by the user, or automatically if the maven project is set to 'Auto-Import'.
As Peter Lawrey mentioned in his comment above, if you add a jar to the project, maven does not know about it and it will be present only in the .iml file.

In general, to search and add a maven dependency, the following has always worked for me: https://stackoverflow.com/a/10178586/325742

Hope this helps !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...