I am using Eclipse Juno integrated with maven plugin.
I have installed JDK 1.6 on my system.
My environment variables are
JAVA_HOME - F:\Program Files\Java\jdk1.6.0_37
MAVEN_HOME - F:\apache-maven-3.0.4
classpath - ;.;%JAVA_HOME%\lib\tools.jar;
Path - C:\Program Files\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Windows Live\Shared;C:\Program Files\QuickTime\QTSystem\;.;%JAVA_HOME%\bin;%MAVEN_HOME%\bin;
My JDK and JRE are working smooth.
Command Line Check :
In my eclipse I am building a new maven web project which should give me a war file.
My pom.xml :
<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.achutha.labs</groupId>
<artifactId>01JsfExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>01JsfExample</name>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<finalName>JavaServerFaces</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
If I do maven clean, its a success.
But when i do maven install it is giving some jdk issues.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building 01JsfExample 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # 01JsfExample ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) # 01JsfExample ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\Workspace\01JsfExample\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
F:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.554s
[INFO] Finished at: Mon Dec 10 06:54:01 IST 2012
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project 01JsfExample: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] F:\Program Files\Java\jre6\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [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/MojoFailureException
My other java programs on eclipse are compiling and running fine.
Except for maven projects. The war file is not getting generated as build is failure due to the above reason.
How to solve this issue ?
Are you running Maven goals in Eclipse? If so, it looks like Eclipse is trying to access the JRE as opposed to the JDK: F:\Program Files\Java\jre6\..\lib\tools.jar
Although JAVA_HOME seems to be set correctly at the Windows level, it could be that in Eclipse you're running the app with a JRE, not a JDK. In Eclipse, have a look at the installed JREs list (Window -> Preferences -> Java -> Installed JREs). If you don't have a JDK, click on 'Edit' after selecting the JRE and in that dialog box enter the location to the JDK.
I am assuming that you are trying to use maven install option from eclipse. Try mvn install from command line. If that fails the issue is with java setup ( installation, path, variable ). Recheck whether your java home is correctly pointing to jdk and not jre. Also ensure eclipse javaw.exe from jdk bin directory.
If cmd line install works then issue is with eclipse java configuration for your maven project. You can try resolving it by -
You should verify the project properties set up in eclipse to ensure the java runtime is the correct one.
You should verify in the project facet the java compilation is set to 1.6
You should set java compilation information in pom.xml sourcejdk and targetjdk tags.
Related
I am trying to add secrets to spring boot app.
so added to pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
<version>3.4.0</version>
</dependency>
Maven version is
xyz_pqr#cloudshell:~/projects/spring-petclinic (xyzprj)$ ./mvnw --version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f) Maven home:
/home/xyz_pqr/.m2/wrapper/dists/apache-maven-3.8.2-bin/1um3pu5poco57pibs3g92d6vrf/apache-maven-3.8.2
Java version: 17.0.4, vendor: Debian, runtime:
/usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform
encoding: ANSI_X3.4-1968 OS name: "linux", version: "5.15.65+", arch:
"amd64", family: "unix" xyz_pqr#cloudshell:~/projects/spring-petclinic
(xyzprj)$
It gives the issue
Failed to execute goal on project spring-petclinic: Could not resolve dependencies for project org.springframework.samples:spring-petclinic:jar:3.0.0-SNAPSHOT: Could not find artifact org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:jar:3.4.0 in spring-snapshots (https://repo.spring.io/snapshot)
The complete error is
[INFO] ------------< org.springframework.samples:spring-petclinic
------------ [INFO] Building petclinic 3.0.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- Downloading from spring-snapshots:
https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.pom
Downloading from spring-milestones:
https://repo.spring.io/milestone/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.pom
Downloading from central:
https://repo.maven.apache.org/maven2/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.pom
[WARNING] The POM for
org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:jar:3.4.0
is missing, no dependency information available Downloading from
spring-snapshots:
https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.jar
Downloading from spring-milestones:
https://repo.spring.io/milestone/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.jar
Downloading from central:
https://repo.maven.apache.org/maven2/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.jar
[INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 3.274 s [INFO] Finished at: 2023-01-14T23:34:50Z
[INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal on project spring-petclinic: Could not
resolve dependencies for project
org.springframework.samples:spring-petclinic:jar:3.0.0-SNAPSHOT: Could
not find artifact
org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:jar:3.4.0
in spring-snapshots (https://repo.spring.io/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
xyz_pqr#cloudshell:~/projects/spring-petclinic (xyzprj)$
The issue is with document at Secret Management
it says
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
but should be
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
so replace org.springframework.cloud with com.google.cloud
I can't remember what I did to cause this problem. When I try to run mvn clean install, I get the following output:
mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building search Maven Webapp 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.slf4j:slf4j-api:jar:12.1.2 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.895 s
[INFO] Finished at: 2014-05-29T21:55:34+02:00
[INFO] Final Memory: 6M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project search: Could not resolve dependencies for project com.ws:search:war:1.0: Failed to collect dependencies at com.oracle.weblogic:weblogic-server-pom:pom:12.1.2-0-0 -> com.oracle.weblogic:com.oracle.state-management.e
xecutor-internal-api_12.1.2:jar:12.1.2: Failed to read artifact descriptor for com.oracle.weblogic:com.oracle.state-management.executor-internal-api_12.1.2:jar:12.1.2: Failure to find com.oracle.state-management:state-management-parent:pom:1.0.0-SNAPSHOT in http://10.68
.20.32:8081/artifactory/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of snapshots has elapsed or updates are forced -> [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
The attempt to find com.oracle.state-management.executor-internal-api_12.1.2:jar:12.1.2 (Note the version: 12.1.2) fails because it originates from the dependency com.oracle.state-management.executor-internal-api_12.1.2 (version 12.1.2 too) while this dependency's pom has the following portion:
<parent>
<artifactId>state-management-parent</artifactId>
<groupId>com.oracle.state-management</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
What surprises me is that there is another version for this dependency (com.oracle.state-management.executor-internal-api_12.1.2) which is 12.1.2-0-0, I believe that this is the right version to refer to, not 12.1.2
What I think supports my assumption is that the output mentions that it failed to find sfl4j dependency with the version 12.1.2 !!
[WARNING] The POM for org.slf4j:slf4j-api:jar:12.1.2 is missing, no dependency information available
I refer to weblogic's dependency this way
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-server-pom</artifactId>
<version>12.1.2-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
How can I fix that ?
For some unearthly reason, weblogic's dependency
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-server-pom</artifactId>
<version>12.1.2-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
had the following version for it's dependencies
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>[12.1.2,12.1.3)</version>
</dependency>
To resolve this, I replaced all [12.1.2,12.1.3) occurrences with 12.1.2-0-0 and now I can install my project again.
I would really appreciate it if someone tells me why was the POM generated this way ?!
I have a Hudson build job that builds a Maven project, and redeploys the resulting artifact to Nexus and to a remote Weblogic instance for testing. I'm trying to create a separate job that would deploy the same artifact to another Weblogic instance, but to do so without recompiling the project and making a new WAR. The rationale here is, the bits already exist and were tested in the development environment, and only if that passes can they be promoted to the development-integration environment. Is this possible?
So far, I have tried:
1) using the existing POM and on the command line and declaring mvn deploy wls:undeploy wls:deploy - This deploys the project WAR to the new environment but also builds the project from scratch. The deploy goal also replaces the previously built project artifact (a snapshot) in Nexus, which makes sense.
2) Tried creating a new POM where the artifact from the previous build is a dependency, and the wls-maven-plugin is the only plugin declared. Running mvn wls:deploy here also fails, for different reasons.
Is there a way to perform such a deployment in a concise manner that I'm missing? Am I using the wrong mechanism (Maven) for this? Should I be using a more procedure based language like Ant? Any insight would be greatly appreciated. (Also if more information is required, please let me know!)
Edit: The redeployment succeeds if the built artifact is locally available in the target directory, and that location is referenced by the properties file. According to the documentation on Oracle's website that parameter can either be local or GAV coordinates. If I use GAV coordinates to pull the artifact directly from Nexus and then push it out to the remote Weblogic, I get the following Maven error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyWebApp 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- wls-maven-plugin:12.1.1.0:redeploy (default-cli) # MyWebApp-deploy-DIT ---
[INFO] ++====================================================================++
[INFO] ++ wls-maven-plugin: redeploy ++
[INFO] ++====================================================================++
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.480s
[INFO] Finished at: Wed Mar 20 10:19:22 EDT 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.oracle.weblogic:wls-maven-plugin:12.1.1.0:redeploy (default-cli) on project MyWebApp-deploy-DIT: Invalid file. Please provide an existing fully qualified path of the file. -> [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
For completeness, I'm also posting the POM I'm using to perform option #2:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>MyWebApp</name>
<parent>
<groupId>org.myorg.maven</groupId>
<artifactId>MyOrg-Parent</artifactId>
<version>2.0</version>
</parent>
<groupId>org.myorg.apps</groupId>
<artifactId>MyWebApp-deploy-DIT</artifactId>
<version>0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<drools.version>5.4.0.Final</drools.version>
<REGION>DEV</REGION>
<MyWebApp_LOGDIR>.</MyWebApp_LOGDIR>
<webapp.jsp.dir>src/main/webapp/WEB-INF/jsp</webapp.jsp.dir>
<buildMsgJsp>buildMsg.jsp</buildMsgJsp>
<DEPLOYMENT_NAME>MyWebApp</DEPLOYMENT_NAME>
<MIDDLEWARE_HOME>/ci/oracle/middleware</MIDDLEWARE_HOME>
<WLS_ADMIN_HOST>lncibd008</WLS_ADMIN_HOST>
<WLS_PORT>7001</WLS_PORT>
<STAGE>true</STAGE>
<!--<SOURCE>${project.build.directory}/MyWebApp-3.7-SNAPSHOT.war</SOURCE>-->
<SOURCE>org.myorg.apps:MyWebApp:war:3.7-SNAPSHOT</SOURCE>
<WLS_TARGETS>server1</WLS_TARGETS>
</properties>
<dependencies>
<dependency>
<groupId>org.myorg.apps</groupId>
<artifactId>MyWebApp</artifactId>
<version>3.7-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>wls-maven-plugin</artifactId>
<version>12.1.1.0</version>
<configuration>
<weblogicHome>wlserver_12.1</weblogicHome>
<upload>true</upload>
<remote>true</remote>
<stage>${STAGE}</stage>
<verbose>true</verbose>
<userConfigFile>wlsconfig/${WLS_ADMIN_HOST}${WLS_PORT}.config</userConfigFile>
<userKeyFile>wlsconfig/${WLS_ADMIN_HOST}${WLS_PORT}.key</userKeyFile>
<adminurl>http://${WLS_ADMIN_HOST}:${WLS_PORT}</adminurl>
<targets>${WLS_TARGETS}</targets>
<source>${SOURCE}</source>-->
<name>${DEPLOYMENT_NAME}</name>
<middlewareHome>C:\Oracle\Middleware</middlewareHome>
</configuration>
</plugin>
</plugins>
</build>
</project>
As you can see I have a commented-out and a GAV . Local one succeeds, GAV fails with the above error.
I am trying to create a custom ant plugin for Maven, based on multiple build scripts. There is a note in the documentation about it: http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html (see "A Note on Multiple Build Scripts"), but I have not been able to make it work.
Here are the scripts:
<root>\src\main\scripts\A.build.xml
-----------------------------------
<project>
<import file="C.build.xml"/>
<target name="hello" depends="dependency">
<echo>Hello, World</echo>
</target>
</project>
<root>\src\main\scripts\A.mojos.xml
-----------------------------------
<pluginMetadata>
<mojos>
<mojo>
<goal>hello</goal>
<call>hello</call>
</mojo>
</mojos>
</pluginMetadata>
<root>\src\main\scripts\B.build.xml
-----------------------------------
<project>
<target name="hello">
<echo>Hello, World</echo>
</target>
</project>
<root>\src\main\scripts\B.mojos.xml
-----------------------------------
<pluginMetadata>
<mojos>
<mojo>
<goal>hello2</goal>
<call>hello</call>
</mojo>
</mojos>
</pluginMetadata>
<root>\src\main\scripts\C.build.xml
-----------------------------------
<project>
<target name="dependency">
<echo>This is the dependency</echo>
</target>
</project>
<root>\pom.xml
--------------
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.myproject.plugins</groupId>
<artifactId>hello-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Hello Plugin</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-script-ant</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.9</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-ant</artifactId>
<version>2.9</version>
</dependency>
</dependencies>
<configuration>
<goalPrefix>hello</goalPrefix>
</configuration>
</plugin>
</plugins>
</build>
</project>
At the root level, I run "mvn clean install", which is successful.
Then I run "mvn org.myproject.plugins:hello-plugin:hello2", which is also successful and produces the "Hello, World" output.
However, when running "mvn org.myproject.plugins:hello-plugin:hello", I get this:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hello Plugin 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- hello-plugin:1.0-SNAPSHOT:hello (default-cli) # hello-plugin ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.531s
[INFO] Finished at: Thu Mar 08 12:52:25 PST 2012
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.myproject.plugins:hello-plugin:1.0-SNAPSHOT:hello (default-cli) on project hello-plug
in: Failed to execute: Executing Ant script: A.build.xml [hello]: Failed to parse. Cannot find C.build.xml imported from
C:\DOCUME~1\joanes\LOCALS~1\Temp\plexus-ant-component9129296102162378706.build.xml -> [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
My question is how does one make this work? By looking at the error, the script is executed in a temporary folder, hence it cannot find the imported C.build.xml. Is there a way to change that? What is the recommended way of accomplishing this?
Try using: import file="${basedir}/src/main/scripts/C.build.xml". It appears maven is re-writing or copying your script to a temp directory then executing it there. It then tries to import C.build.xml from that directory because there's no other path information for C.build.xml.
I'm trying to create my own maven archetype. For now, I'm going through this tutorial [here][1] without success. I'm able to build the archetype project okay, but when I try to generate a project from that archetype I get the error below. Maven can't seem to find the archetype I created. Can any one spot my problem? Is there some other recomended tutorial for createing a maven archetype? Thanks.
Maven version 3.0.3
Build Error:
AR3Y35-LAPTOP:EclipseWS Albert$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeGroupId=com.myarch.archetypes -DarchetypeArtifactId=component-archetype -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.0:generate (default-cli) # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.0:generate (default-cli) # standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.0:generate (default-cli) # standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Specified archetype not found.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.389s
[INFO] Finished at: Fri Sep 23 02:33:55 PDT 2011
[INFO] Final Memory: 7M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.0:generate (default-cli) on project standalone-pom: The desired archetype does not exist (com.myarch.archetypes:component-archetype:1.0) -> [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/MojoFailureException
AR3Y35-LAPTOP:EclipseWS Albert$
prototype pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.myarch.templates</groupId>
<artifactId>component-template</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<name>${group}</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
archetype.xml
<archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>component-archetype</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
<allowPartial>true</allowPartial>
</archetype>
For using a customized archetype, there has to be an entry made in the archetype-catalog.xml file which resides in the .m2/repository/archetype-catalog.xml in your home directory. For doing so, you need to install the archetype by using the following command:
mvn install archetype:update-local-catalog
After that, you will be able to use your new archetype while creating a new Maven project with the mvn archetype:generate command.
I needed to include -DarchetypeVersion={my.archetype.version} in the mvn archetpe:generate command
In my case the problem was that:
- update-local-catalog goal created file ~/.m2/repository/archetype-catalog.xml
- generate goal searches for file ~/.m2/archetype-catalog.xml
copying the file was a workaround. Not sure how I've fixed this. Sure now with maven 3.5.4 everything is ok.
It's telling you :
[WARNING] Specified archetype not found.
Did you install your archetype with
mvn install
before trying to use it ?
Executing the mvn install resolves the problem, after executing that from idea the problem got resolved.
From my own experience, You have to search for your groupId is accessible in the below link or not
http://repo.maven.apache.org/maven2/archetype-catalog.xml
I found out I had typo error then I've got error.