Author: rl...@jb... Date: 2005-12-06 15:03:01 -0500 (Tue, 06 Dec 2005) New Revision: 1716 Added: trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/pom.xml trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JJTreeMojo.java trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JavaCCMojo.java trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/scripts/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/apt/ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/apt/index.apt trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/site.xml trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/pom.xml trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/AbstractRmiMojo.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/DefaultRmiCompilerManager.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/NoSuchRmiCompilerException.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/PackageRmiMojo.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/ProcessClassesRmiMojo.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompiler.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerException.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerManager.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/SunRmiCompiler.java trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/resources/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/resources/META-INF/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/resources/META-INF/plexus/ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/resources/META-INF/plexus/components.xml Log: initial entry of plugins Added: trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/pom.xml =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/pom.xml 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/pom.xml 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,34 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>mojo</artifactId> + <groupId>org.codehaus.mojo</groupId> + <version>4</version> + </parent> + <artifactId>javacc-maven-plugin</artifactId> + <packaging>maven-plugin</packaging> + <version>0.6.1-SNAPSHOT</version> + <name>Maven Javacc Plugin</name> + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-project</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-compiler-api</artifactId> + <version>1.5.1</version> + </dependency> + <dependency> + <groupId>plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>javacc</groupId> + <artifactId>javacc</artifactId> + <version>3.2</version> + </dependency> + </dependencies> +</project> Added: trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JJTreeMojo.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JJTreeMojo.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JJTreeMojo.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,279 @@ +package org.codehaus.mojo.javacc; + +/* + * Copyright 2001-2005 The Codehaus. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.compiler.util.scan.InclusionScanException; +import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner; +import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner; +import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping; +import org.codehaus.plexus.util.FileUtils; +import org.javacc.jjtree.JJTree; + +/** + * @goal jjtree + * @phase generate-sources + * @description Goal which parse a JJ file and transform it to Java Source + * Files. + * @author jesse <jes...@gm...> + * @version $Id: JJTreeMojo.java 893 2005-11-21 20:18:03Z jesse $ + */ +public class JJTreeMojo extends AbstractMojo { + + /** + * @parameter expression="${buildNodeFiles}" + */ + private Boolean buildNodeFiles; + + /** + * @parameter expression="${jjFile}" + */ + private String jjFile; + + /** + * @parameter expression="${multi}" + */ + private Boolean multi; + + /** + * @parameter expression="${nodeDefaultVoid}" + */ + private Boolean nodeDefaultVoid; + + /** + * @parameter expression="${nodeFactory}" + */ + private Boolean nodeFactory; + + /** + * @parameter expression="${nodeScopeHook}" + */ + private Boolean nodeScopeHook; + + /** + * @parameter expression="${nodeUsesParser}" + */ + private Boolean nodeUsesParser; + + /** + * @parameter expression="${staticOption}" + */ + private Boolean staticOption; + + /** + * @parameter expression="${visitor}" + */ + private Boolean visitor; + + /** + * @parameter expression="${nodePackage}" + */ + private String nodePackage; + + /** + * @parameter expression="${visitorException}" + */ + private String visitorException; + + /** + * @parameter expression="${nodePrefix}" + */ + private String nodePrefix; + + /** + * Directory where the JJT file(s) are located. + * + * @parameter expression="${basedir}/src/main/jjtree" + * @required + */ + private File sourceDirectory; + + /** + * Directory where the output Java Files will be located. + * + * @parameter expression="${project.build.directory}/generated-sources/jjtree" + * @required + */ + private File outputDirectory; + + /** + * the directory to store the processed .jjt files + * + * @parameter expression="${basedir}/target" + */ + private String timestampDirectory; + + + + /** + * The granularity in milliseconds of the last modification date for testing + * whether a source needs recompilation + * + * @parameter expression="${lastModGranularityMs}" default-value="0" + */ + private int staleMillis; + + /** + * @parameter expression="${project}" + * @required + */ + private MavenProject project; + + public void execute() throws MojoExecutionException { + if (!outputDirectory.exists()) { + + outputDirectory.mkdirs(); + + } + + if (!FileUtils.fileExists(timestampDirectory)) { + FileUtils.mkdir(timestampDirectory); + } + + Set staleGrammars = computeStaleGrammars(); + + if (staleGrammars.isEmpty()) { + getLog().info("Nothing to process - all grammars are up to date"); + if (project != null) { + project.addCompileSourceRoot(outputDirectory.getAbsolutePath()); + } + return; + } + + for (Iterator i = staleGrammars.iterator(); i.hasNext();) { + File jjTreeFile = (File) i.next(); + try { + JJTree jjtree = new JJTree(); + jjtree.main(generateArgumentList(jjTreeFile.getAbsolutePath())); + + + FileUtils.copyFileToDirectory(jjTreeFile, new File( + timestampDirectory)); + } catch (Exception e) { + throw new MojoExecutionException("JJTree execution failed", e); + } + } + + if (project != null) { + project.addCompileSourceRoot(outputDirectory.getAbsolutePath()); + + } + } + + private String[] generateArgumentList(String jjTreeFilename) { + + ArrayList argsList = new ArrayList(); + + if (buildNodeFiles != null) { + argsList.add("-BUILD_NODE_FILES=" + buildNodeFiles.toString()); + } + + if (multi != null) { + argsList.add("-MULTI=" + multi); + } + + if (nodeDefaultVoid != null) { + argsList.add("-NODE_DEFAULT_VOID=" + nodeDefaultVoid); + } + + if (nodeFactory != null) { + argsList.add("-NODE_FACTORY=" + nodeFactory); + } + + if (nodePackage != null) { + argsList.add("-NODE_PACKAGE=" + nodePackage); + } + + if (nodePrefix != null) { + argsList.add("-NODE_PREFIX=" + nodePrefix); + } + + if (nodeScopeHook != null) { + argsList.add("-NODE_SCOPE_HOOK=" + nodeScopeHook); + } + + if (nodeUsesParser != null) { + argsList.add("-NODE_USES_PARSER=" + nodeUsesParser); + } + + if (visitor != null) { + argsList.add("-VISITOR=" + visitor); + } + + if (staticOption != null) { + argsList.add("-STATIC=" + staticOption); + } + + if (visitorException != null) { + argsList.add("-VISITOR_EXCEPTION=\'" + visitorException + "\'"); + } + + argsList.add("-OUTPUT_DIRECTORY=" + outputDirectory); + + argsList.add(jjTreeFilename); + + getLog().debug("argslist: " + argsList.toString()); + + return (String[]) argsList.toArray(new String[argsList.size()]); + } + + private Set computeStaleGrammars() throws MojoExecutionException { + File outDir = new File(timestampDirectory); + File sourceDir = sourceDirectory; + Set staleSources = new HashSet(); + + if (jjFile != null) { + this.getLog().info("Generating grammar for single file: " + jjFile); + File grammarFile = new File(sourceDirectory + "/" + jjFile); + staleSources.add(grammarFile); + } else { + SuffixMapping mapping = new SuffixMapping(".jjt", ".jjt"); + SuffixMapping mappingCAP = new SuffixMapping(".JJT", ".JJT"); + + SourceInclusionScanner scanner = new StaleSourceScanner(staleMillis); + + scanner.addSourceMapping(mapping); + scanner.addSourceMapping(mappingCAP); + + try { + staleSources.addAll(scanner.getIncludedSources(sourceDir, + outDir)); + } catch (InclusionScanException e) { + throw new MojoExecutionException( + "Error scanning source root: \'" + sourceDir + + "\' for stale grammars to reprocess.", e); + } + } + return staleSources; + } + + /** + * @return Returns the jjFile. + */ + public String getJjFile() { + return jjFile; + } +} Added: trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JavaCCMojo.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JavaCCMojo.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/main/java/org/codehaus/mojo/javacc/JavaCCMojo.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,414 @@ +package org.codehaus.mojo.javacc; + +/* + * Copyright 2001-2005 The Codehaus. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.compiler.util.scan.InclusionScanException; +import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner; +import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner; +import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; + + +/** + * @goal javacc + * @phase generate-sources + * @description Goal which parse a JJ file and transform it to Java Source Files. + * @author jr...@ex... + * @author jesse <jes...@gm...> + * @version $Id: JavaCCMojo.java 951 2005-11-29 19:53:12Z jesse $ + */ +public class JavaCCMojo + extends AbstractMojo +{ + /** + * @parameter expression=${lookAhead}" + */ + private Integer lookAhead; + + /** + * @parameter expression="${choiceAmbiguityCheck}" + */ + private Integer choiceAmbiguityCheck; + + /** + * @parameter expression=${otherAmbiguityCheck}" + */ + private Integer otherAmbiguityCheck; + + /** + * @parameter expression=${isStatic}" + */ + private Boolean isStatic; + + /** + * @parameter expression="${debugParser}" + */ + private Boolean debugParser; + + /** + * @parameter expression="${debugLookAhead}" + */ + private Boolean debugLookAhead; + + /** + * @parameter expression="${debugTokenManager}" + */ + private Boolean debugTokenManager; + + /** + * @parameter expression="${optimizeTokenManager}" + */ + private Boolean optimizeTokenManager; + + /** + * @parameter expression="${errorReporting}" + */ + private Boolean errorReporting; + + /** + * @parameter expression="${javaUnicodeEscape}" + */ + private Boolean javaUnicodeEscape; + + /** + * @parameter expression="${unicodeInput}" + */ + private Boolean unicodeInput; + + /** + * @parameter expression="${ignoreCase}" + */ + private Boolean ignoreCase; + + /** + * @parameter expression="${commonTokenAction}" + */ + private Boolean commonTokenAction; + + /** + * @parameter expression="${userTokenManager}" + */ + private Boolean userTokenManager; + + /** + * @parameter expression="${userCharStream}" + */ + private Boolean userCharStream; + + /** + * @parameter expression="${buildParser}" + */ + private Boolean buildParser; + + /** + * @parameter expression="${buildTokenManager}" + */ + private Boolean buildTokenManager; + + /** + * @parameter expression="${sanityCheck}" + */ + private Boolean sanityCheck; + + /** + * @parameter expression="${forceLaCheck}" + */ + private Boolean forceLaCheck; + + /** + * @parameter expression="${cacheTokens}" + */ + private Boolean cacheTokens; + + /** + * @parameter expression="${keepLineColumn}" + */ + private Boolean keepLineColumn; + + /** + * @parameter expression="${packageName}" + */ + private String packageName; + + /** + * Directory where the JJ file(s) are located. + * @parameter expression="${basedir}/src/main/javacc" + * @required + */ + private File sourceDirectory; + + /** + * Directory where the output Java Files will be located. + * @parameter expression="${project.build.directory}/generated-sources/javacc" + * @required + */ + private File outputDirectory; + + /** + * the directory to store the processed .jj files + * + * @parameter expression="${basedir}/target" + */ + private String timestampDirectory; + + /** + * The granularity in milliseconds of the last modification + * date for testing whether a source needs recompilation + * + * @parameter expression="${lastModGranularityMs}" default-value="0" + */ + private int staleMillis; + + /** + * @parameter expression="${project}" + * @required + */ + private MavenProject project; + + public void execute() + throws MojoExecutionException + { + // check packageName for . vs / + if ( packageName != null ) + { + packageName = StringUtils.replace(packageName, '.', File.separatorChar); + } + + if ( outputDirectory.exists() ) + { + if ( packageName != null ) + { + FileUtils.mkdir( outputDirectory + File.separator + packageName ); + } + else + { + try { + outputDirectory.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + if ( !FileUtils.fileExists( timestampDirectory ) ) + { + FileUtils.mkdir( timestampDirectory ); + } + + Set staleGrammars = computeStaleGrammars(); + + if ( staleGrammars.isEmpty() ) + { + getLog().info( "Nothing to process - all grammars are up to date" ); + if ( project != null ) + { + project.addCompileSourceRoot( outputDirectory.getAbsolutePath() ); + } + return; + } + + for ( Iterator i = staleGrammars.iterator(); i.hasNext(); ) + { + File javaccFile = (File) i.next(); + try + { + org.javacc.parser.Main.mainProgram( generateJavaCCArgumentList( javaccFile.getAbsolutePath()) ); + + FileUtils.copyFileToDirectory(javaccFile, new File(timestampDirectory)); + } + catch ( Exception e ) + { + throw new MojoExecutionException( "JavaCC execution failed", e ); + } + } + + if ( project != null ) + { + project.addCompileSourceRoot( outputDirectory.getAbsolutePath() ); + project.addCompileSourceRoot( "C:\\projects\\maven-jboss-head\\jboss-head\\server\\target\\gensrc" ); + } + } + + + private String[] generateJavaCCArgumentList(String javaccInput) { + + ArrayList argsList = new ArrayList(); + + if ( lookAhead != null ) + { + argsList.add("-LOOKAHEAD=" + lookAhead); + } + + if ( choiceAmbiguityCheck != null) + { + argsList.add("-CHOICE_AMBIGUITY_CHECK=" + choiceAmbiguityCheck); + } + + if ( otherAmbiguityCheck != null ) + { + argsList.add("-OTHER_AMBIGUITY_CHECK=" + otherAmbiguityCheck); + } + + if ( isStatic != null ) + { + argsList.add("-STATIC=" + isStatic); + } + + if ( debugParser != null ) + { + argsList.add("-DEBUG_PARSER=" + debugParser); + } + + if ( debugLookAhead != null ) + { + argsList.add("-DEBUG_LOOKAHEAD=" + debugLookAhead); + } + + if ( debugTokenManager != null ) + { + argsList.add("-DEBUG_TOKEN_MANAGER=" + debugTokenManager); + } + + if ( optimizeTokenManager != null ) + { + argsList.add("-OPTIMIZE_TOKEN_MANAGER=" + optimizeTokenManager); + } + + if ( errorReporting != null ) + { + argsList.add("-ERROR_REPORTING="+ errorReporting); + } + + if ( javaUnicodeEscape != null ) + { + argsList.add("-JAVA_UNICODE_ESCAPE=" + javaUnicodeEscape); + } + + if ( unicodeInput != null ) + { + argsList.add("-UNICODE_INPUT=" + unicodeInput); + } + + if ( ignoreCase != null ) + { + argsList.add("-IGNORE_CASE=" + ignoreCase); + } + + if ( commonTokenAction != null ) + { + argsList.add("-COMMON_TOKEN_ACTION=" + commonTokenAction); + } + + if ( userTokenManager != null ) + { + argsList.add("-USER_TOKEN_MANAGER=" + userTokenManager); + } + + if ( userCharStream != null ) + { + argsList.add("-USER_CHAR_STREAM=" + userCharStream); + } + + if ( buildParser != null ) + { + argsList.add("-BUILD_PARSER=" + buildParser); + } + + if ( buildTokenManager != null ) + { + argsList.add("-BUILD_TOKEN_MANAGER=" + buildTokenManager); + } + + if ( sanityCheck != null ) + { + argsList.add("-SANITY_CHECK=" + sanityCheck); + } + + if ( forceLaCheck != null ) + { + argsList.add("-FORCE_LA_CHECK=" + forceLaCheck); + } + + if ( cacheTokens != null ) + { + argsList.add("-CACHE_TOKENS=" + cacheTokens); + } + + if ( keepLineColumn != null ) + { + argsList.add("-KEEP_LINE_COLUMN=" + keepLineColumn); + } + + if ( packageName != null ) + { + argsList.add("-OUTPUT_DIRECTORY:" + outputDirectory + File.separator + packageName ); + } + else + { + argsList.add("-OUTPUT_DIRECTORY:" + outputDirectory ); + } + + argsList.add(javaccInput); + + getLog().debug("argslist: " + argsList.toString()); + + return (String[])argsList.toArray(new String[argsList.size()]); + } + + private Set computeStaleGrammars() throws MojoExecutionException + { + SuffixMapping mapping = new SuffixMapping( ".jj", ".jj" ); + SuffixMapping mappingCAP = new SuffixMapping( ".JJ", ".JJ" ); + + SourceInclusionScanner scanner = new StaleSourceScanner( staleMillis ); + + scanner.addSourceMapping( mapping ); + scanner.addSourceMapping( mappingCAP); + + File outDir = new File( timestampDirectory ); + + Set staleSources = new HashSet(); + + File sourceDir = sourceDirectory ; + + try + { + staleSources.addAll( scanner.getIncludedSources( sourceDir, outDir ) ); + } + catch ( InclusionScanException e ) + { + throw new MojoExecutionException( "Error scanning source root: \'" + sourceDir + "\' for stale grammars to reprocess.", e ); + } + + return staleSources; + } + + +} + Added: trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/apt/index.apt =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/apt/index.apt 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/apt/index.apt 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,97 @@ + ------ + Maven 2 JavaCC plugin + ------ + <jr...@ex...> + Jesse McConnell <jes...@gm...> + ------ + July 27 2005 + ------ + +Maven 2 JavaCC plugin + + This plugin is for processing javacc files into java sources. + + http://www.javacc.org + + This plugin will process all *.jj files in the sourceDirectory into a + common generated sources output directory. This will occur during the + generate-resources phase and the sources directory will be added to the project + for the compile phase. + +Available Configuration Options: (param - default value) + + * sourceDirectory - src/main/javacc + + * outputDirectory - target/generated-sources/javacc + + * timestampDirectory - target (used so grammers are not constantly regenerated) + + * lookAhead - 1 + + * choiceAmbiguityCheck - 2 + + * otherAmbiguityCheck - 1 + + * isStatic - true + + * debugParser - false + + * debugLookAhead - false + + * debugTokenManager - false + + * optimizeTokenManager - true + + * errorReporting - true + + * javaUnicodeEscape - false + + * unicodeInput - false + + * ignoreCase - false + + * commonTokenAction - false + + * userTokenManager - false + + * userCharStream - false + + * buildParser - true + + * buildTokenManager - true + + * sanityCheck - true + + * forceLaCheck - false + + * cacheTokens - false + + * keepLineColumn - true + + [] + +Usage: + +------------------- +<project> + ... + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>javacc-maven-plugin</artifactId> + <version>0.6-SNAPSHOT</version> + <executions> + <execution> + <goals> + <goal>javacc</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + ... + </build> + ... +</project> +------------------- Added: trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/site.xml =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/site.xml 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/javacc-maven-plugin/src/site/site.xml 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,22 @@ +<project name="Mojo"> + <bannerLeft> + <name>Mojo</name> + <src>/images/mojo_logo.png</src> + <href>http://mojo.codehaus.org</href> + </bannerLeft> + <bannerRight> + <name>Codehaus</name> + <src>http://mojo.codehaus.org/images/codehaus-small.png</src> + <href>http://www.codehaus.org</href> + </bannerRight> + <body> + <links> + <item name="Mojo" href="http://mojo.codehaus.org"/> + <item name="Maven" href="http://maven.apache.org/maven2"/> + </links> + <menu name="Mojo"> + <item name="mojo" href="http://mojo.codehaus.org"/> + </menu> + ${reports} + </body> +</project> Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/pom.xml =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/pom.xml 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/pom.xml 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,34 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>maven-plugin-parent</artifactId> + <groupId>org.apache.maven.plugins</groupId> + <version>2.0</version> + </parent> + <artifactId>maven-rmic-plugin</artifactId> + <version>1.0-alpha-1-SNAPSHOT</version> + <packaging>maven-plugin</packaging> + <name>Maven RMI Compiler Plugin</name> + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>2.0-alpha-3</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-archiver</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>plexus</groupId> + <artifactId>plexus-archiver</artifactId> + <version>1.0-alpha-1</version> + </dependency> + <dependency> + <groupId>plexus</groupId> + <artifactId>plexus-container-default</artifactId> + <version>1.0-alpha-3</version> + </dependency> + </dependencies> +</project> Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/AbstractRmiMojo.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/AbstractRmiMojo.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/AbstractRmiMojo.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,299 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2005 Trygve Laugstol. All Rights Reserved. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.maven.artifact.DependencyResolutionRequiredException; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; + +/** + * @author <a href="mailto:tr...@in...">Trygve Laugstøl</a> + * @version $Id: AbstractRmiMojo.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public abstract class AbstractRmiMojo + extends AbstractMojo +{ + // ---------------------------------------------------------------------- + // Configurable parameters + // ---------------------------------------------------------------------- + + + /** + * @parameter expression="${project}" + * @required + * @readonly + */ + private MavenProject project; + /** + * The class or classes to compile with the RMI compiler. + * + * @parameter + * @required + */ + private List remoteClasses; + + /** + * Specifies compiler location to use + * @parameter expression="sun" + * @required + */ + private String compilerId; + + /** + * Specifies path to where the rmic outputs should be stored + * @parameter expression="${project.build.directory}/rmi-stub-classes" + * @required + */ + private File outputClasses; + + /** + * The directory output location of generated source, casues -keepgenerated flag to be used + * @parameter + */ + private File sourcebase; + + /** + * Specify the jdk version for the generated stub code. Specifiy "1.1" to pass the "-v1.1" option + * to RMIC + * @parameter + */ + private String stubversion; + + /** + * Specify an inclusion pattern or comma seperated list of includsion patterns + * not yet implemented + * @parameter + */ + private String includes; + + /** + * Specify an exclusion pattern or comma seperated list of inclusion patterns + * not yet implemented + * @parameter + */ + private String excludes; + + /** + * indicates whether default excludes should be used or not ("yes/no") Default excludes are used when omitted + * @parameter + */ + private String defaultExcludes; + + /** + * check that classes implement Remote before handing them to rmic (default is false) + * @parameter expression="false" + */ + private boolean verify; + + /** + * indicates that portable (RMI/IIOP) stubs should be generated + * @parameter expression="false" + */ + private boolean iiop; + + /** + * additional arguments for IIOP class generation + * valid arguments are -always or -alwaysgenerate + * -nolocalstubs, -noValueMethods, -poa + * @parameter + */ + private List iiopOpts; + + /** + * indicates that IDL output files shold be generated + * @parameter expression=false + */ + private boolean idl; + + /** + * additional arguments for IDL file generation + * valid arguments are -always or -alwaysgenerate + * -factory, -idlModule + * + */ + private List idlopts; + + /** + * generate debug info (passes -g to rmic). Defaults to false + * @parameter expression="false" + */ + private boolean debug; + + + // ---------------------------------------------------------------------- + // Constant parameters + // ---------------------------------------------------------------------- + + /** + * @parameter expression="${project.build.outputDirectory}" + * @required + * @readonly + */ + private File classes; + + + //private List compileClasspaths; + + /** + * Specifies the path rmic used to look up classes. This option overrides + * the default or the CLASSPATH environment variable if it is set. + * Directories are seperated by semicolons. + * @parameter + */ + private String classPath; + + public List getRemoteClasses() + { + return remoteClasses; + } + + public String getCompilerId() + { + return compilerId; + } + + public File getOutputClasses() + { + return outputClasses; + } + + public File getClasses() + { + return classes; + } + + public List getClasspath() + { + List classPaths = new ArrayList(); + + StringTokenizer tokenizer = new StringTokenizer( classPath, ";" ); + + while ( tokenizer.hasMoreElements() ) + { + String s = (String) tokenizer.nextElement(); + + s = s.trim(); + + classPaths.add( s ); + } + + try { + for (Iterator it=project.getCompileClasspathElements().iterator(); it.hasNext(); ) + { + classPaths.add((String) it.next()); + } + } catch (DependencyResolutionRequiredException e) { + this.getLog().error("Error when resolving the classpath"); + + } + + + + return classPaths; + + } + + protected List getSourceClasses() + { + List sourceClasses = new ArrayList(); + + + + for (Iterator it=getRemoteClasses().iterator(); it.hasNext(); ) + { + sourceClasses.add((String) it.next()); + } + + /* + while (it.hasNext()) + // sourceClasses.add(it.) + /* + StringTokenizer tokenizer = new StringTokenizer( getRemoteClasses(), "," ); + + while ( tokenizer.hasMoreElements() ) + { + String s = (String) tokenizer.nextElement(); + + s = s.trim(); + + sourceClasses.add( s ); + } +*/ + return sourceClasses; + } + /** + * @return Returns the debug. + */ + public boolean getDebug() { + return debug; + } + /** + * @return Returns the defaultExcludes. + */ + public String getDefaultExcludes() { + return defaultExcludes; + } + /** + * @return Returns the excludes. + */ + public String getExcludes() { + return excludes; + } + /** + * @return Returns the idl. + */ + public boolean getIdl() { + return idl; + } + /** + * @return Returns the idlopts. + */ + public List getIdlopts() { + return idlopts; + } + /** + * @return Returns the iiop. + */ + public boolean getIiop() { + return iiop; + } + /** + * @return Returns the iiopOpts. + */ + public List getIiopOpts() { + return iiopOpts; + } + /** + * @return Returns the includes. + */ + public String getIncludes() { + return includes; + } + /** + * @return Returns the sourcebase. + */ + public File getSourcebase() { + return sourcebase; + } + /** + * @return Returns the stubversion. + */ + public String getStubversion() { + return stubversion; + } + /** + * @return Returns the verify. + */ + public boolean getVerify() { + return verify; + } +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/DefaultRmiCompilerManager.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/DefaultRmiCompilerManager.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/DefaultRmiCompilerManager.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,54 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2004, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.Map; + +/** + * @author <a href="mailto:tr...@in...">Trygve Laugstøl</a> + * @version $Id: DefaultRmiCompilerManager.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public class DefaultRmiCompilerManager implements RmiCompilerManager +{ + /** + * @plexus.requirement role=RmiCompiler + */ + private Map rmiCompilers; + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + public RmiCompiler getRmiCompiler( String id ) + throws NoSuchRmiCompilerException + { + RmiCompiler rmiCompiler = (RmiCompiler) rmiCompilers.get( id ); + + if ( rmiCompiler == null ) + { + throw new NoSuchRmiCompilerException( id ); + } + + return rmiCompiler; + } +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/NoSuchRmiCompilerException.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/NoSuchRmiCompilerException.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/NoSuchRmiCompilerException.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,43 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2004, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * @author <a href="mailto:tr...@in...">Trygve Laugstøl</a> + * @version $Id: NoSuchRmiCompilerException.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public class NoSuchRmiCompilerException + extends Exception +{ + private String id; + + public NoSuchRmiCompilerException( String id ) + { + this.id = id; + } + + public String getId() + { + return id; + } +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/PackageRmiMojo.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/PackageRmiMojo.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/PackageRmiMojo.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,87 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2005 Trygve Laugstol. All Rights Reserved. + */ + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; +import java.util.jar.JarFile; + +import org.apache.maven.archiver.MavenArchiver; +import org.apache.maven.archiver.MavenArchiveConfiguration; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; + +import org.codehaus.plexus.archiver.jar.JarArchiver; +import org.codehaus.plexus.archiver.ArchiverException; + +/** + * @goal package + * + * @phase package + * + * @requiresDependencyResolution + * + * @description Packages the RMI stubs and client classes. + * + * @author <a href="mailto:tr...@in...">Trygve Laugstøl</a> + * @version $Id: PackageRmiMojo.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public class PackageRmiMojo + extends AbstractRmiMojo +{ + /** + * @parameter expression="${project.build.directory}" + * @required + */ + private File target; + + /** + * @parameter expression="${project.build.finalname}" + * @required + */ + private String finalName; + + /** + * @parameter expression="${project}" + */ + private MavenProject project; + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + public void execute() + throws MojoExecutionException + { + File clientJar = new File( target, finalName + "-client.jar" ); + + try + { + JarArchiver jarArchiver = new JarArchiver(); + + jarArchiver.setDestFile( clientJar ); + + // ---------------------------------------------------------------------- + // Add the *_Stub classes + // ---------------------------------------------------------------------- + + for ( Iterator it = getSourceClasses().iterator(); it.hasNext(); ) + { + String clazz = (String) it.next(); + + String[] includes = new String[] { + clazz.replace( '.', '/' ) + "_Stub.class", + }; + + jarArchiver.addDirectory( getOutputClasses(), includes, new String[ 0 ] ); + } + } + catch ( ArchiverException e ) + { + throw new MojoExecutionException( "Could not create the client jar", e ); + } + } +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/ProcessClassesRmiMojo.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/ProcessClassesRmiMojo.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/ProcessClassesRmiMojo.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,149 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2004, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.maven.plugin.MojoExecutionException; + +/** + * @goal process-classes + * + * @phase process-classes + * + * @requiresDependencyResolution + * + * @description Enhances the application data objects. + * + * @author <a href="mailto:tr...@in...">Trygve Laugstøl </a> + * @version $Id: ProcessClassesRmiMojo.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public class ProcessClassesRmiMojo extends AbstractRmiMojo { + // ---------------------------------------------------------------------- + // Configurable parameters + // ---------------------------------------------------------------------- + + /** + * @parameter expression="sun" + * @required + */ + private String compilerId; + + // ---------------------------------------------------------------------- + // Constant parameters + // ---------------------------------------------------------------------- + + /** + * @parameter expression="${component.org.apache.maven.plugin.rmic.RmiCompilerManager}" + * @required + * @readonly + */ + private RmiCompilerManager rmiCompilerManager; + + public void execute() throws MojoExecutionException { + RmiCompiler rmiCompiler; + + try { + rmiCompiler = rmiCompilerManager.getRmiCompiler(compilerId); + } catch (NoSuchRmiCompilerException e) { + throw new MojoExecutionException("No such RMI compiler installed '" + + compilerId + "'."); + } + + if (!getOutputClasses().isDirectory()) { + if (!getOutputClasses().mkdirs()) { + throw new MojoExecutionException( + "Could not make output directory: " + "'" + + getOutputClasses().getAbsolutePath() + "'."); + } + } + + try { + List classPaths = getClasspath(); + + File[] compileClasspath = new File[classPaths.size()]; + + Iterator it; + + int i; + + for (it = classPaths.iterator(), i = 0; it.hasNext(); i++) { + compileClasspath[i] = new File((String) it.next()); + } + + List sourceClasses = getSourceClasses(); + + if (getVerify() == true) { + this.getLog().info("Verify is not yet implemented."); + + for (it = sourceClasses.iterator(), i = 0; it.hasNext(); i++) { + boolean result = this.isValidRmiRemote((String) it.next()); + + } + + } + + rmiCompiler.execute(compileClasspath, sourceClasses, + getOutputClasses(), getSourcebase(), getStubversion(), + getIncludes(), getExcludes(), getDefaultExcludes(), + getVerify(), getIiop(), getIiopOpts(), getIdl(), + getIdlopts(), getDebug()); + + this.getLog().info("RMIC completed."); + } catch (RmiCompilerException e) { + throw new MojoExecutionException( + "Error while executing the RMI compiler.", e); + } + } + + public boolean isValidRmiRemote(String classname) { + try { + //TODO: need to define our own classloader to load the class + Class testClass = Class.forName(classname); + // One cannot RMIC an interface for "classic" RMI (JRMP) + if (testClass.isInterface() && !getIiop() && !getIdl()) { + return false; + } + + } catch (ClassNotFoundException e) { + this.getLog().error( + "Unable to verify class " + classname + + ". It could not be found."); + } catch (NoClassDefFoundError e) { + this.getLog().error( + "Unable to verify class " + classname + + ". It is not defined."); + } catch (Throwable t) { + this.getLog().error( + "Unable to verify class " + classname + + ". Loading caused Exception: " + t.getMessage()); + } + // we only get here if an exception has been thrown + return false; + } + +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompiler.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompiler.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompiler.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,41 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2004, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.List; +import java.io.File; +import java.net.URL; + +/** + * @author <a href="mailto:tr...@in...">Trygve Laugstøl</a> + * @version $Id: RmiCompiler.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public interface RmiCompiler +{ + String ROLE = RmiCompiler.class.getName(); + + void execute( File[] classLoader, List remoteClasses, File outputClasses, File sourceBase, String stubVersion, String includes, + String excludes, String defaultExcludes, boolean verify, boolean iiop, List iiopOpts, boolean idl, List idlOpts, + boolean debug) + throws RmiCompilerException; +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerException.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerException.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerException.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,41 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2004, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * @author <a href="mailto:tr...@in...">Trygve Laugstøl</a> + * @version $Id: RmiCompilerException.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public class RmiCompilerException + extends Exception +{ + public RmiCompilerException( String message ) + { + super( message ); + } + + public RmiCompilerException( String message, Throwable cause ) + { + super( message, cause ); + } +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerManager.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerManager.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/RmiCompilerManager.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,11 @@ +package org.apache.maven.plugin.rmic; + +/** + * @author <a href="mailto:tr...@in...">Trygve Laugstøl</a> + * @version $Id: RmiCompilerManager.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public interface RmiCompilerManager +{ + RmiCompiler getRmiCompiler( String id ) + throws NoSuchRmiCompilerException; +} Added: trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/SunRmiCompiler.java =================================================================== --- trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/SunRmiCompiler.java 2005-12-06 19:36:59 UTC (rev 1715) +++ trunk/labs/jbossbuild/projects/maven-plugins/maven-rmic-plugin/src/main/java/org/apache/maven/plugin/rmic/SunRmiCompiler.java 2005-12-06 20:03:01 UTC (rev 1716) @@ -0,0 +1,263 @@ +package org.apache.maven.plugin.rmic; + +/* + * Copyright (c) 2004, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.io.File; +import java.io.OutputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.codehaus.plexus.logging.AbstractLogEnabled; + +/** + * @author <a href="mailto:tr...@in...">Trygve Laugstøl </a> + * @version $Id: SunRmiCompiler.java 337 2005-07-26 21:33:58Z trygvis $ + */ +public class SunRmiCompiler extends AbstractLogEnabled implements RmiCompiler { + // ---------------------------------------------------------------------- + // RmiCompiler Implementation + // ---------------------------------------------------------------------- + +public void execute( File[] path, List remoteClasses, File outputClasses, File sourceBase, String stubVersion, String includes, + String excludes, String defaultExcludes, boolean verify, boolean iiop, List iiopOpts, boolean idl, List idlOpts, + boolean debug) + throws RmiCompilerException + { + //first we must find the path to the SUN rmic classes + String[] classes = { + "sun.rmi.rmic.newrmic.Main", + "sun.rmi.rmic.Main", + }; + + List elements = new ArrayList(); + + elements.addAll( Arrays.asList( path ) ); + + File toolsJar = new File( System.getProperty( "java.home" ), "../lib/tools.jar" ); + + if ( toolsJar.isFile() ) + { + elements.add( toolsJar ); + } + + URL[] classpath = new URL[ elements.size() ]; + + for ( int i = 0; i < elements.size(); i++ ) + { + classpath[ i ] = fileToURL( (File) elements.get( i ) ); + } + + ClassLoader classLoader = new URLClassLoader( classpath, ClassLoader.getSystemClassLoader() ); + + Class clazz = null; + + for ( int i = 0; i < classes.length; i++ ) + { + String className = classes[ i ]; + + clazz = findClass( classLoader, className ); + + if ( clazz != null ) + { + break; + } + } + + //throw error if classes are not found + if ( clazz == null ) + { + getLogger().info( "Looked for these classes:" ); + + for ( int i = 0; i < classes.length; i++ ) + { + String className = classes[ i ]; + + getLogger().info( " * " + className ); + } + + getLogger().info( "With this classpath:" ); + + for ( int it = 0; it < classpath.length; it++ ) + { + URL url = classpath[ it ]; + + getLogger().info( " * " + url.t... [truncated message content] |