That worked! Thanks! Can someone make changes to the tutorial on the website with the directions below? I'd be glad to if someone gives me the password. Thanks, siegfried
-----Original Message----- From: Tim Kettler [mailto:[EMAIL PROTECTED] Sent: Friday, August 31, 2007 9:39 AM To: Maven Users List Subject: Re: Trouble with mojo tutorial Hi, perhaps it would be better if you would start from scratch, to have a clean state. Then just do this: 1. mvn archetype:create \ -DgroupId=sample.plugin \ -DartifactId=maven-hello-plugin \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DarchetypeArtifactId=maven-archetype-mojo This will generate a simple plugin project with a sample mojo. 2. Add the 'GreetingsMojo.java' to 'src/main/java/sample/plugin' 3. Do an 'mvn install'. 4. Now you can use the plugin from every maven project by executing: mvn sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi There is no need to specify the hello-plugin in the <build/><plugins/> section of a pom unless you want it to execute automatically during a build or lock its version. You may also want to read the chapters on plugin development in the two maven books [1], [2], -Tim [1] http://www.sonatype.com/book/ [2] http://www.devzuz.com/web/guest/products/resources#BBWM siegfried schrieb: > Thanks Wayne. > I tried that but no luck! The tutorial does not specify where to put > c:/dev/sandboxes/maven/sample-mojo/maven-hello-plugin/src/main/java/sample/p > lugin/GreetingMojo.java. I suspect I don't have this in the correct > directory. Since I did the steps out of order, I already had a > src/main/java/sample/plugin directory which looked like a logical place to > put GreetingMojo.java. Where is the pom.xml in the tutorial looking for > GreetingMojo.java? > > Thanks, > Siegfried > > cd c:/dev/sandboxes/maven/sample-mojo/maven-hello-plugin/ > mvn install > [INFO] Scanning for projects... > > [INFO] > ---------------------------------------------------------------------------- > > [INFO] Building Sample Parameter-less Maven Plugin > > [INFO] task-segment: [install] > > [INFO] > ---------------------------------------------------------------------------- > > [INFO] artifact org.apache.maven.plugins:maven-plugin-plugin: checking for > updates from central > > Downloading: > http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugin-plugin/2 > .3/maven-plugin-plugin-2.3.pom > > 4/6K > 6/6K > 6K downloaded > > Downloading: > http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugin-plugin/2 > .3/maven-plugin-plugin-2.3.jar > > 4/21K > 8/21K > 12/21K > 16/21K > 20/21K > 21/21K > 21K downloaded > > [INFO] artifact org.apache.maven.plugins:maven-jar-plugin: checking for > updates from central > > [INFO] artifact org.apache.maven.plugins:maven-install-plugin: checking for > updates from central > > Downloading: > http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/ > 2.2/maven-install-plugin-2.2.pom > > 2/2K > 2K downloaded > > Downloading: > http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/ > 2.2/maven-install-plugin-2.2.jar > > 4/15K > 8/15K > 12/15K > 15/15K > 15K downloaded > > [INFO] > ------------------------------------------------------------------------ > > [ERROR] BUILD FAILURE > > [INFO] > ------------------------------------------------------------------------ > > [INFO] A required plugin was not found: Plugin could not be found - check > that the goal name is correct: Unable to download the artifact from any > repository > > > > Try downloading the file manually from the project website. > > > > Then, install it using the command: > > mvn install:install-file -DgroupId=sample.plugin > -DartifactId=maven-hello-plugin \ > -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin -Dfile=/path/to/file > > Alternatively, if you host your own repository you can deploy the file > there: mvn deploy:deploy-file -DgroupId=sample.plugin > -DartifactId=maven-hello-plugin \ > -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin -Dfile=/path/to/file > \ > -Durl=[url] -DrepositoryId=[id] > > > > > > sample.plugin:maven-hello-plugin:maven-plugin:1.0-SNAPSHOT > > > > from the specified remote repositories: > > central (http://repo1.maven.org/maven2) > > > > sample.plugin:maven-hello-plugin:maven-plugin:1.0-SNAPSHOT > > > > from the specified remote repositories: > > central (http://repo1.maven.org/maven2) > > > > [INFO] > ------------------------------------------------------------------------ > > [INFO] For more information, run Maven with the -e switch > > [INFO] > ------------------------------------------------------------------------ > > [INFO] Total time: 5 seconds > > [INFO] Finished at: Fri Aug 31 09:17:20 MDT 2007 > > [INFO] Final Memory: 3M/6M > > [INFO] > ------------------------------------------------------------------------ > > > Compilation exited abnormally with code 1 at Fri Aug 31 09:17:20 > cd c:/dev/sandboxes/maven/sample-mojo/maven-hello-plugin/ > mvn sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi > [INFO] Scanning for projects... > > [INFO] Cannot find mojo descriptor for: > 'sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi' - Treating as > non-aggregator. > > [INFO] > ---------------------------------------------------------------------------- > > [INFO] Building Sample Parameter-less Maven Plugin > > [INFO] task-segment: > [sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi] > > [INFO] > ---------------------------------------------------------------------------- > > [INFO] > ------------------------------------------------------------------------ > > [ERROR] BUILD FAILURE > > [INFO] > ------------------------------------------------------------------------ > > [INFO] A required plugin was not found: Plugin could not be found - check > that the goal name is correct: Unable to download the artifact from any > repository > > > > Try downloading the file manually from the project website. > > > > Then, install it using the command: > > mvn install:install-file -DgroupId=sample.plugin > -DartifactId=maven-hello-plugin \ > -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin -Dfile=/path/to/file > > Alternatively, if you host your own repository you can deploy the file > there: mvn deploy:deploy-file -DgroupId=sample.plugin > -DartifactId=maven-hello-plugin \ > -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin -Dfile=/path/to/file > \ > -Durl=[url] -DrepositoryId=[id] > > > > > > sample.plugin:maven-hello-plugin:maven-plugin:1.0-SNAPSHOT > > > > from the specified remote repositories: > > central (http://repo1.maven.org/maven2) > > > > sample.plugin:maven-hello-plugin:maven-plugin:1.0-SNAPSHOT > > > > from the specified remote repositories: > > central (http://repo1.maven.org/maven2) > > > > [INFO] > ------------------------------------------------------------------------ > > [INFO] For more information, run Maven with the -e switch > > [INFO] > ------------------------------------------------------------------------ > > [INFO] Total time: < 1 second > > [INFO] Finished at: Fri Aug 31 09:19:59 MDT 2007 > > [INFO] Final Memory: 1M/4M > > [INFO] > ------------------------------------------------------------------------ > > > Compilation exited abnormally with code 1 at Fri Aug 31 09:19:59 > > -----Original Message----- > From: Wayne Fay [mailto:[EMAIL PROTECTED] > Sent: Friday, August 31, 2007 12:49 AM > To: Maven Users List > Subject: Re: Trouble with mojo tutorial > > You need to run "mvn install" to install your plugin into the local repo > cache. > > Then you can test your plugin in another project by specifying "mvn > ...:sayhi". > > Wayne > > On 8/31/07, siegfried <[EMAIL PROTECTED]> wrote: >> Thanks Wayne, that "-U" appeared to work. >> >> Now I started out the tutorial with the command >> mvn -U archetype:create \ >> -DgroupId=sample.plugin \ >> -DartifactId=maven-hello-plugin \ >> -DarchetypeGroupId=org.apache.maven.archetypes \ >> -DarchetypeArtifactId=maven-archetype-mojo >> >> because the tutorial did not tell you where to place the files pom.xml and >> GreetingMojo.java. So I just put GreetingMojo down in the directly with > the >> other java source code. Then I clobbered the pom.xml file with pom.xml > from >> http://maven.apache.org/guides/plugin/guide-java-plugin-development.html. >> >> Below is my pom.xml which I copied from >> http://maven.apache.org/guides/plugin/guide-java-plugin-development.html . >> Below that are the results when I try to "mvn >> sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi" as per the >> instructions. >> >> What am I doing wrong? I am not seeing "Hello, World". >> >> I believe I have copied the >> > c:/dev/sandboxes/maven/sample-mojo/maven-hello-plugin/src/main/java/sample/p >> lugin/GreetingMojo.java correctly from that web page. >> >> So then when I realized that I executed the command " mvn -U >> archetype:create... " too soon and tried moving GreetingMojo.java to >> c:/dev/sandboxes/maven/sample-mojo/maven-hello-plugin/GreetingMojo.java > and >> running the command again but that did not help. >> >> >> Thanks, >> Siegfried >> >> >> Here is my c:/dev/sandboxes/maven/sample-mojo/maven-hello-plugin/pom.xml. >> Does it need to begin with a <?xml version="1.0" encoding="utf-8"?> tag? > Why >> not? >> >> <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> >> <groupId>sample.plugin</groupId> >> <artifactId>maven-hello-plugin</artifactId> >> <packaging>maven-plugin</packaging> >> <version>1.0-SNAPSHOT</version> >> <name>Sample Parameter-less Maven Plugin</name> >> <dependencies> >> <dependency> >> <groupId>org.apache.maven</groupId> >> <artifactId>maven-plugin-api</artifactId> >> <version>2.0</version> >> </dependency> >> </dependencies> >> <build> >> <plugins> >> <plugin> >> <groupId>sample.plugin</groupId> >> <artifactId>maven-hello-plugin</artifactId> >> <version>1.0-SNAPSHOT</version> >> </plugin> >> </plugins> >> </build> >> </project> >> >> Here are the results: >> cd c:/dev/sandboxes/maven/sample-mojo/maven-hello-plugin/ >> mvn sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi >> [INFO] Scanning for projects... >> >> [INFO] Cannot find mojo descriptor for: >> 'sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi' - Treating as >> non-aggregator. >> >> [INFO] >> > ---------------------------------------------------------------------------- >> [INFO] Building Sample Parameter-less Maven Plugin >> >> [INFO] task-segment: >> [sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi] >> >> [INFO] >> > ---------------------------------------------------------------------------- >> [INFO] >> ------------------------------------------------------------------------ >> >> [ERROR] BUILD FAILURE >> >> [INFO] >> ------------------------------------------------------------------------ >> >> [INFO] A required plugin was not found: Plugin could not be found - check >> that the goal name is correct: Unable to download the artifact from any >> repository >> >> >> >> Try downloading the file manually from the project website. >> >> >> >> Then, install it using the command: >> >> mvn install:install-file -DgroupId=sample.plugin >> -DartifactId=maven-hello-plugin \ >> -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin > -Dfile=/path/to/file >> Alternatively, if you host your own repository you can deploy the file >> there: mvn deploy:deploy-file -DgroupId=sample.plugin >> -DartifactId=maven-hello-plugin \ >> -Dversion=1.0-SNAPSHOT -Dpackaging=maven-plugin > -Dfile=/path/to/file >> \ >> -Durl=[url] -DrepositoryId=[id] >> >> >> >> >> >> sample.plugin:maven-hello-plugin:maven-plugin:1.0-SNAPSHOT >> >> >> >> from the specified remote repositories: >> >> central (http://repo1.maven.org/maven2) >> >> >> >> sample.plugin:maven-hello-plugin:maven-plugin:1.0-SNAPSHOT >> >> >> >> from the specified remote repositories: >> >> central (http://repo1.maven.org/maven2) >> >> >> >> [INFO] >> ------------------------------------------------------------------------ >> >> [INFO] For more information, run Maven with the -e switch >> >> [INFO] >> ------------------------------------------------------------------------ >> >> [INFO] Total time: < 1 second >> >> [INFO] Finished at: Fri Aug 31 00:04:30 MDT 2007 >> >> [INFO] Final Memory: 1M/4M >> >> [INFO] >> ------------------------------------------------------------------------ >> >> >> Compilation exited abnormally with code 1 at Fri Aug 31 00:04:30 >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -----Original Message----- >> From: Wayne Fay [mailto:[EMAIL PROTECTED] >> Sent: Wednesday, August 29, 2007 3:56 PM >> To: Maven Users List >> Subject: Re: Trouble with mojo tutorial >> >> Try mvn -U ... to force an update. >> >> 1.0-alpha-5 was a "failed release". The only available versions are -4 and >> -6. >> >> Wayne >> >> On 8/29/07, siegfried <[EMAIL PROTECTED]> wrote: >>> I'm trying to follow the instructions at >>> > http://maven.apache.org/guides/plugin/guide-java-plugin-development.html. >>> Below are the results. >>> >>> >>> >>> Am I experiencing some problem with the public maven repositories or is >> this >>> a bug in maven 2.0.7? (Or did I do something wrong?) >>> >>> >>> >>> What would be the wget command to get maven-archetype-creator:jar as the >>> error message suggests? >>> >>> >>> >>> Thanks, >>> >>> Siegfried >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> cd c:/dev/sandboxes/maven/sample-mojo/ >>> >>> mvn archetype:create \ >>> >>> -DgroupId=sample.plugin \ >>> >>> -DartifactId=maven-hello-plugin \ >>> >>> -DarchetypeGroupId=org.apache.maven.archetypes \ >>> >>> -DarchetypeArtifactId=maven-archetype-mojo >>> >>> [INFO] Scanning for projects... >>> >>> [INFO] Searching repository for plugin with prefix: 'archetype'. >>> >>> [INFO] >>> > ---------------------------------------------------------------------------- >>> [INFO] Building Maven Default Project >>> >>> [INFO] task-segment: [archetype:create] (aggregator-style) >>> >>> [INFO] >>> > ---------------------------------------------------------------------------- >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cor >>> e/1.0-alpha-5/maven-archetype-core-1.0-alpha-5.pom >>> >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cor >>> e/1.0-alpha-5/maven-archetype-core-1.0-alpha-5.pom >>> >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cre >>> ator/1.0-alpha-5/maven-archetype-creator-1.0-alpha-5.pom >>> >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cre >>> ator/1.0-alpha-5/maven-archetype-creator-1.0-alpha-5.pom >>> >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cre >>> ator/1.0-alpha-5/maven-archetype-creator-1.0-alpha-5.jar >>> >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cre >>> ator/1.0-alpha-5/maven-archetype-creator-1.0-alpha-5.jar >>> >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cor >>> e/1.0-alpha-5/maven-archetype-core-1.0-alpha-5.jar >>> >>> Downloading: >>> > http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype-cor >>> e/1.0-alpha-5/maven-archetype-core-1.0-alpha-5.jar >>> >>> [INFO] >>> ------------------------------------------------------------------------ >>> >>> [ERROR] BUILD ERROR >>> >>> [INFO] >>> ------------------------------------------------------------------------ >>> >>> [INFO] Failed to resolve artifact. >>> >>> >>> >>> Missing: >>> >>> ---------- >>> >>> 1) org.apache.maven.archetype:maven-archetype-creator:jar:1.0-alpha-5 >>> >>> >>> >>> >>> >>> Try downloading the file manually from the project website. >>> >>> >>> >>> >>> >>> Then, install it using the command: >>> >>> mvn install:install-file -DgroupId=org.apache.maven.archetype >>> -DartifactId=maven-archetype-creator \ >>> >>> -Dversion=1.0-alpha-5 -Dpackaging=jar -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.archetype >>> -DartifactId=maven-archetype-creator \ >>> >>> -Dversion=1.0-alpha-5 -Dpackaging=jar -Dfile=/path/to/file \ >>> >>> -Durl=[url] -DrepositoryId=[id] >>> >>> >>> >>> >>> >>> Path to dependency: >>> >>> 1) >>> org.apache.maven.plugins:maven-archetype-plugin:maven-plugin:1.0-alpha-6 >>> >>> 2) >>> org.apache.maven.archetype:maven-archetype-creator:jar:1.0-alpha-5 >>> >>> >>> >>> >>> >>> 2) org.apache.maven.archetype:maven-archetype-core:jar:1.0-alpha-5 >>> >>> >>> >>> >>> >>> Try downloading the file manually from the project website. >>> >>> >>> >>> >>> >>> Then, install it using the command: >>> >>> mvn install:install-file -DgroupId=org.apache.maven.archetype >>> -DartifactId=maven-archetype-core \ >>> >>> -Dversion=1.0-alpha-5 -Dpackaging=jar -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.archetype >>> -DartifactId=maven-archetype-core \ >>> >>> -Dversion=1.0-alpha-5 -Dpackaging=jar -Dfile=/path/to/file \ >>> >>> -Durl=[url] -DrepositoryId=[id] >>> >>> >>> >>> >>> >>> Path to dependency: >>> >>> 1) >>> org.apache.maven.plugins:maven-archetype-plugin:maven-plugin:1.0-alpha-6 >>> >>> 2) >>> org.apache.maven.archetype:maven-archetype-core:jar:1.0-alpha-5 >>> >>> >>> >>> >>> >>> ---------- >>> >>> 2 required artifacts are missing. >>> >>> >>> >>> for artifact: >>> >>> > org.apache.maven.plugins:maven-archetype-plugin:maven-plugin:1.0-alpha-6 >>> >>> >>> >>> >>> from the specified remote repositories: >>> >>> apache.snapshots > (http://people.apache.org/repo/m2-snapshot-repository), >>> central (http://repo1.maven.org/maven2) >>> >>> >>> >>> >>> >>> >>> >>> [INFO] >>> ------------------------------------------------------------------------ >>> >>> [INFO] For more information, run Maven with the -e switch >>> >>> [INFO] >>> ------------------------------------------------------------------------ >>> >>> [INFO] Total time: 6 seconds >>> >>> [INFO] Finished at: Wed Aug 29 13:09:04 MDT 2007 >>> >>> [INFO] Final Memory: 2M/4M >>> >>> [INFO] >>> ------------------------------------------------------------------------ >>> >>> >>> >>> Compilation exited abnormally with code 1 at Wed Aug 29 13:09:05 >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
