Maven Application got 5 Modules and 6 POM.xml files - maven-2

I am working on existing Maven Project
Which has got 5 modules like
<modules>
<module>sideware</module>
<module>xmlmodule</module>
<module>business</module>
<module>service</module>
<module>helper</module>
</modules>
Each Module has got a one POM.xml file as well as
and one main Pom.xml
I am using Eclipse to run the POM.xml files as Maven install
Please tell me do i need to run the Each POM.xml indivudally ??
Or can i run the Parent POM.xml file once ??
Thank you

I think it is sufficient to run the parent POM. See the question What is the "reactor" in Maven? about the plugin that implements that for Maven. So you have the following options (at least):
Build the parent POM, which will build all modules as well.
Build a module individually, and it will build its dependencies automatically.
Here is a small experiment I have done on my own:
Build automatically == false.
Build a multi-module Maven project, and add there 2 modules.
Insert some code into the modules.
Run mvn install inside eclipse
As a result, I get the following output in the console:
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] MultiModuleExample
[INFO] Unnamed - com.tsi.mli:sideware:jar:0.0.1-SNAPSHOT
[INFO] Unnamed - com.tsi.mli:business:jar:0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Building MultiModuleExample
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\projekte\setools-work\build\example-build-projekte\indigo-full\ws\multi-module-example\pom.xml to C:\Users\mliebelt\.m2\repository\com\tsi\mli\multi-module-example\0.0.1-SNAPSHOT\multi-module-example-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.tsi.mli:sideware:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [install]
...
The directory structure I have got is:
multi-module-example/
business/
src/
target/
.classpath
.project
pom.xml
sideware/
...
src/
.project
pom.xml

Related

Random 403 error during resolving packages on Artifactory

We use Artifactory Pro.
We have a virtual repo in which we've stored the installer of yarn 23.04.
On another instance we have running a Jenkins 1 server. We have some maven project and our maven goal is to perform:
clean source:jar install -DskipTests -Pyarn -X
We use the profile yarn so a yarn install will be executed.
We are not using any proxy about our configuration. We have turned them off explicitly
Most of the time the jenkins job works:
[INFO] yarn install v0.23.4
[INFO] [1/4] Resolving packages...
[INFO] [2/4] Fetching packages...
[ERROR] warning fsevents#1.1.1: The platform "linux" is incompatible with this module.
[INFO] info "fsevents#1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[INFO] [3/4] Linking dependencies...
[ERROR] warning "ng2-translate#5.0.0" has incorrect peer dependency "#angular/core#^2.0.0".
[ERROR] warning "ng2-translate#5.0.0" has incorrect peer dependency "#angular/http#^2.0.0".
[ERROR] warning "sass-loader#6.0.5" has incorrect peer dependency "webpack#^2.0.0".
[INFO] [4/4] Building fresh packages...
[INFO] success Saved lockfile.
But on certain occasions it fails:
[INFO] yarn install v0.23.4
[INFO] [1/4] Resolving packages...
[ERROR] an unexpected error occurred: "http://xxx/artifactory/api/npm/npm/xxx: Request\ "http://xxx/artifactory/api/npm/npm/xxx" returned a 403
The yarn is in our artifactory. So we think the only issue can be a 'bad connection' between jenkins and Artifactory or the apache which is running above Artifactory.
Is there some specific setting in Apache that could cause this behaviour of Artifactory?

Gradle build throwing error

I have created a sample gradle project on intellij.
I go to the project root folder and execute the following:
./gradlew installDist
I am getting this error:
FAILURE: Build failed with an exception.
What went wrong:
Task 'installDist' not found in root project 'HelloWorld'.
Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Please please let me know the resolution for this. I have spent one hour on this with no resolution.
If you are going to try a gradle with a sample project, the best way to do it - not to use any IDE at all.
First of all create a directory for your project and make it as a current directory by doing so
mkdir myapp
cd myapp
Then check if gradle is in your PATH by
gradle -v
You should see something like this
Gradle 2.12
Now you are ready to create your first gradle build script. You may do it in vim editor or what ever you want.
vim build.gradle
And just copy and paste following code in your build.gradle file
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.11'
}
So you may try do build the empty project
gradle build
also you may want to add gradle wrapper
gradle wrapper
this command will add gradlw scripts and gradledirectory with wrapper binaries.
So you are ready to add the java code to your project. You should create folders defined in java-project layout
mkdir src
mkdir src/main
mkdir src/main/java
mkdir src/test
mkdir src/test/java
As a result you will get
myapp # project root folder
└── src
├── main
│   └── java       
└── test
└── java
And then just import this project in your IDE.
I had the same problem with springboot application.Then i saw there is no install dir under build.
Then add id 'application' to build.gradle--plugs, it worked well.
This problem shows we dont know gradle no doubt.

compilation error with apache giraph (building from the trunk)

===================Below is the error============================
[INFO] Building jar:
/home/rob/dev/apache/giraph-trunk/giraph/giraph-core/target/giraph-1.1.0-SNAPSHOT-for-hadoop-0.20.203.0-jar-with-dependencies.jar
[INFO] Total time: 1:12.383s
[INFO] Finished at: Mon Jan 20 17:25:46 PST 2014
[INFO] Final Memory: 31M/119M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project giraph-examples: Could not
resolve dependencies for project
org.apache.giraph:giraph-examples:jar:1.1.0-SNAPSHOT: Failure to find
org.apache.giraph:giraph-core:jar:tests:1.1.0-SNAPSHOT in
http://repo1.maven.org/maven2 was cached in the local repository,
resolution will not be reattempted until the update interval of
central has elapsed or updates are forced -> [Help 1]
I have hadoop installed on my machine but I am unable to build it.
thanks for looking into it.
It looks like you compile only the example project. You have to import parent project, core project and example project. Then to compile Giraph trunk for pure Yarn you can use:
clean package -P hadoop_yarn -Dhadoop.version=2.2.0 -DskipTests
BTW. what is your java version, maven version?

Running a task post maven install

I want to run a simple exec command post maven install phase. What is the simplest way possible to achieve this? (without adding new plugins)
If you want to run this command as part of the normal build lifecycle, there is no other way than binding the exec goal on the install phase:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>my-exec</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<inherited>false</inherited>
</execution>
</executions>
<configuration>
<executable>COMMAND</executable>
</configuration>
</plugin>
</plugins>
</build>
I did a simple test using the configuration above (using ls as "COMMAND") with a freshly created maven project and running mvn install produces the following output:
$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-exec-testcase
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
...
[INFO] [install:install {execution: default-install}]
[INFO] Installing /home/pascal/Projects/maven-exec-testcase/target/maven-exec-testcase-1.0-SNAPSHOT.jar to /home/pascal/.m2/repository/com/mycompany/app/maven-exec-testcase/1.0-SNAPSHOT/maven-exec-testcase-1.0-SNAPSHOT.jar
[INFO] [exec:exec {execution: my-exec}]
[INFO] pom.xml
[INFO] src
[INFO] target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12 seconds
[INFO] Finished at: Tue Jan 05 19:26:04 CET 2010
[INFO] Final Memory: 11M/75M
[INFO] ------------------------------------------------------------------------
As we can see, the command is executed at the end of the install phase (after the copy of the artifact to the local repository).
And if you really don't want to add the snippet to your pom, then you'll have to explicitly call exec:exec after install on the command line as suggested by whaley.
The maven default lifecycle ends with the install and deploy goals - there is no pre- and post- version of those goals.
Potential options would be to:
Bind the exec:exec mojo to with the deploy phase. I would warn you against that idea as the deploy phase is really meant to deploy artifacts to a remote maven repository.
Run the exec:exec mojo after the install goal in your mvn invocation... e.g.:
mvn clean install exec:exec -Dexec.executable="yourcommand" -Dexec.args="arguments"
If you have a multi-module project, create another module at the end of your <modules> and bind exec:exec to any of the usual goals within that module. This will force this particular module to run last assuming other criteria the reactor looks at isn't met. A common strategy I employ with maven projects I work on is "when in doubt, create another module".

Maven: Missing: org.apache.maven.wagon:wagon-ftp:jar:1.0-rc1-SNAPSHOT

I'm new to Maven so I may be missing something obvious, but
I've got a maven project and when I try to "mvn package" this project it fails with
ERROR BUILD ERROR INFO
------------------------------------------------------------------------ [INFO] Failed to resolve artifact.
Missing:
---------- 1) org.apache.maven.wagon:wagon-ftp:jar:1.0-rc1-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.apache.maven.wagon -DartifactId=wagon-ftp -Dversion=1.0-rc1-SNAPSHOT -Dpackaging=ja r -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.apache.maven.wagon -DartifactId=wagon-ftp -Dversion=1.0-rc1-SNAPSHOT -Dpackaging=jar
-Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) com.cgs:domain:jar:1.0-SNAPSHOT
2) org.apache.maven.wagon:wagon-ftp:jar:1.0-rc1-SNAPSHOT
----------
1 required artifact is missing.
for artifact: com.cgs:domain:jar:1.0-SNAPSHOT
from the specified remote repositories: ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2)
The first thing I don't understand is the version it requires 1.0-rc1-SNAPSHOT. The projects' site says the current version is 1.0-beta-5. And I suppose beta goes before RC.
Anyway, I've tried to download the latest wagon-ftp JAR (1.0 beta 6 jar) and deploy it according to the instructions in the error message.
But guess what, this gave me the same error.
I've just found the solution as I was typing the end of this question.
The problem was that I was running "mvn install:install-file" from the same directory the failing project POM was in. It installed fine when I run it from another directory without a pom.xml.