Index: kernel/pom.xml =================================================================== --- kernel/pom.xml (revision 4270) +++ kernel/pom.xml (working copy) @@ -66,21 +66,14 @@ ${project.version} - - true - - generateInhabitants + generate-inhabitants - test - process-test-classes - - true - + test-inhabitants - generateInhabitants + generate-test-inhabitants Index: hk2-locator/pom.xml =================================================================== --- hk2-locator/pom.xml (revision 4270) +++ hk2-locator/pom.xml (working copy) @@ -59,18 +59,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/InhabitantsGeneratorMojo.java =================================================================== --- hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/InhabitantsGeneratorMojo.java (revision 4270) +++ hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/InhabitantsGeneratorMojo.java (working copy) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -40,31 +40,15 @@ package org.jvnet.hk2.generator.maven; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.jvnet.hk2.generator.HabitatGenerator; /** - * Calls the generator with maven + * Generates inhabitant * - * @goal generateInhabitants + * @goal generate-inhabitants * @phase process-classes * @requiresDependencyResolution test */ -public class MavenInhabitantsGenerator extends AbstractMojo { - /** - * The maven project. - * - * @parameter expression="${project}" @required @readonly - */ - protected MavenProject project; +public class InhabitantsGeneratorMojo extends AbstractInhabitantsGeneratorMojo { /** * @parameter expression="${project.build.outputDirectory}" @@ -72,120 +56,17 @@ private File outputDirectory; /** - * @parameter expression="${project.build.testOutputDirectory}" + * @parameter default-value="true" */ - private File testOutputDirectory; - - /** - * @parameter - */ - private boolean verbose; - - /** - * @parameter - */ - private String locator; - - /** - * @parameter - */ - private boolean test = false; - - /** - * @parameter - */ private boolean noswap; - - /** - * @parameter expression="${supportedProjectTypes}" default-value="jar" - */ - private String supportedProjectTypes; - - /** - * This method will compile the inhabitants file based on - * the classes just compiled - */ + @Override - public void execute() throws MojoFailureException { - List projectTypes = Arrays.asList(supportedProjectTypes.split(",")); - if(!projectTypes.contains(project.getPackaging())){ - return; - } - - File output = (test)? testOutputDirectory : outputDirectory; - output.mkdirs(); - - if (!output.exists()) { - getLog().info("Exiting hk2-inhabitant-generator because could not find output directory " + - output.getAbsolutePath()); - return; - } - - if (verbose) { - getLog().info(""); - getLog().info("hk2-inhabitant-generator generating into location " + output.getAbsolutePath()); - getLog().info(""); - } - - LinkedList arguments = new LinkedList(); - - arguments.add(HabitatGenerator.FILE_ARG); - arguments.add(output.getAbsolutePath()); - - if (verbose) { - arguments.add(HabitatGenerator.VERBOSE_ARG); - } - - if (locator != null) { - arguments.add(HabitatGenerator.LOCATOR_ARG); - arguments.add(locator); - } - - arguments.add(HabitatGenerator.SEARCHPATH_ARG); - arguments.add(getBuildClasspath()); - - if (noswap) { - arguments.add(HabitatGenerator.NOSWAP_ARG); - } - - String argv[] = arguments.toArray(new String[arguments.size()]); - - int result = HabitatGenerator.embeddedMain(argv); - - if (result != 0) { - throw new MojoFailureException("Could not generate inhabitants file for " + - (test ? testOutputDirectory : outputDirectory)); - } + protected boolean getNoSwap() { + return noswap; } - - private String getBuildClasspath() { - StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); - sb.append(File.pathSeparator); - } - - List artList = new ArrayList(project.getArtifacts()); - Iterator i = artList.iterator(); - - if (i.hasNext()) { - sb.append(i.next().getFile().getPath()); - while (i.hasNext()) { - sb.append(File.pathSeparator); - sb.append(i.next().getFile().getPath()); - } - } - - String classpath = sb.toString(); - if(verbose){ - getLog().info(""); - getLog().info("-- Classpath --"); - getLog().info(""); - getLog().info(classpath); - getLog().info(""); - } - return classpath; - } + @Override + protected File getOutputDirectory() { + return outputDirectory; + } } Index: hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/TestInhabitantsGeneratorMojo.java =================================================================== --- hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/TestInhabitantsGeneratorMojo.java (revision 4270) +++ hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/TestInhabitantsGeneratorMojo.java (working copy) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -40,152 +40,33 @@ package org.jvnet.hk2.generator.maven; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.jvnet.hk2.generator.HabitatGenerator; /** - * Calls the generator with maven + * Generates inhabitant * - * @goal generateInhabitants - * @phase process-classes + * @goal generate-test-inhabitants + * @phase test-compile * @requiresDependencyResolution test */ -public class MavenInhabitantsGenerator extends AbstractMojo { - /** - * The maven project. - * - * @parameter expression="${project}" @required @readonly - */ - protected MavenProject project; +public class TestInhabitantsGeneratorMojo extends AbstractInhabitantsGeneratorMojo { /** - * @parameter expression="${project.build.outputDirectory}" + * @parameter expression="${project.build.testOutputDirectory}" */ private File outputDirectory; /** - * @parameter expression="${project.build.testOutputDirectory}" + * @parameter default-value="false" */ - private File testOutputDirectory; - - /** - * @parameter - */ - private boolean verbose; - - /** - * @parameter - */ - private String locator; - - /** - * @parameter - */ - private boolean test = false; - - /** - * @parameter - */ private boolean noswap; - - /** - * @parameter expression="${supportedProjectTypes}" default-value="jar" - */ - private String supportedProjectTypes; - - /** - * This method will compile the inhabitants file based on - * the classes just compiled - */ + @Override - public void execute() throws MojoFailureException { - List projectTypes = Arrays.asList(supportedProjectTypes.split(",")); - if(!projectTypes.contains(project.getPackaging())){ - return; - } - - File output = (test)? testOutputDirectory : outputDirectory; - output.mkdirs(); - - if (!output.exists()) { - getLog().info("Exiting hk2-inhabitant-generator because could not find output directory " + - output.getAbsolutePath()); - return; - } - - if (verbose) { - getLog().info(""); - getLog().info("hk2-inhabitant-generator generating into location " + output.getAbsolutePath()); - getLog().info(""); - } - - LinkedList arguments = new LinkedList(); - - arguments.add(HabitatGenerator.FILE_ARG); - arguments.add(output.getAbsolutePath()); - - if (verbose) { - arguments.add(HabitatGenerator.VERBOSE_ARG); - } - - if (locator != null) { - arguments.add(HabitatGenerator.LOCATOR_ARG); - arguments.add(locator); - } - - arguments.add(HabitatGenerator.SEARCHPATH_ARG); - arguments.add(getBuildClasspath()); - - if (noswap) { - arguments.add(HabitatGenerator.NOSWAP_ARG); - } - - String argv[] = arguments.toArray(new String[arguments.size()]); - - int result = HabitatGenerator.embeddedMain(argv); - - if (result != 0) { - throw new MojoFailureException("Could not generate inhabitants file for " + - (test ? testOutputDirectory : outputDirectory)); - } + protected boolean getNoSwap() { + return noswap; } - - private String getBuildClasspath() { - StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); - sb.append(File.pathSeparator); - } - - List artList = new ArrayList(project.getArtifacts()); - Iterator i = artList.iterator(); - - if (i.hasNext()) { - sb.append(i.next().getFile().getPath()); - while (i.hasNext()) { - sb.append(File.pathSeparator); - sb.append(i.next().getFile().getPath()); - } - } - - String classpath = sb.toString(); - if(verbose){ - getLog().info(""); - getLog().info("-- Classpath --"); - getLog().info(""); - getLog().info(classpath); - getLog().info(""); - } - return classpath; - } + @Override + protected File getOutputDirectory() { + return outputDirectory; + } } Index: hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/MavenInhabitantsGenerator.java =================================================================== --- hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/MavenInhabitantsGenerator.java (revision 4270) +++ hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/MavenInhabitantsGenerator.java (working copy) @@ -1,191 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.jvnet.hk2.generator.maven; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.jvnet.hk2.generator.HabitatGenerator; - -/** - * Calls the generator with maven - * - * @goal generateInhabitants - * @phase process-classes - * @requiresDependencyResolution test - */ -public class MavenInhabitantsGenerator extends AbstractMojo { - /** - * The maven project. - * - * @parameter expression="${project}" @required @readonly - */ - protected MavenProject project; - - /** - * @parameter expression="${project.build.outputDirectory}" - */ - private File outputDirectory; - - /** - * @parameter expression="${project.build.testOutputDirectory}" - */ - private File testOutputDirectory; - - /** - * @parameter - */ - private boolean verbose; - - /** - * @parameter - */ - private String locator; - - /** - * @parameter - */ - private boolean test = false; - - /** - * @parameter - */ - private boolean noswap; - - /** - * @parameter expression="${supportedProjectTypes}" default-value="jar" - */ - private String supportedProjectTypes; - - /** - * This method will compile the inhabitants file based on - * the classes just compiled - */ - @Override - public void execute() throws MojoFailureException { - List projectTypes = Arrays.asList(supportedProjectTypes.split(",")); - if(!projectTypes.contains(project.getPackaging())){ - return; - } - - File output = (test)? testOutputDirectory : outputDirectory; - output.mkdirs(); - - if (!output.exists()) { - getLog().info("Exiting hk2-inhabitant-generator because could not find output directory " + - output.getAbsolutePath()); - return; - } - - if (verbose) { - getLog().info(""); - getLog().info("hk2-inhabitant-generator generating into location " + output.getAbsolutePath()); - getLog().info(""); - } - - LinkedList arguments = new LinkedList(); - - arguments.add(HabitatGenerator.FILE_ARG); - arguments.add(output.getAbsolutePath()); - - if (verbose) { - arguments.add(HabitatGenerator.VERBOSE_ARG); - } - - if (locator != null) { - arguments.add(HabitatGenerator.LOCATOR_ARG); - arguments.add(locator); - } - - arguments.add(HabitatGenerator.SEARCHPATH_ARG); - arguments.add(getBuildClasspath()); - - if (noswap) { - arguments.add(HabitatGenerator.NOSWAP_ARG); - } - - String argv[] = arguments.toArray(new String[arguments.size()]); - - int result = HabitatGenerator.embeddedMain(argv); - - if (result != 0) { - throw new MojoFailureException("Could not generate inhabitants file for " + - (test ? testOutputDirectory : outputDirectory)); - } - } - - private String getBuildClasspath() { - StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); - sb.append(File.pathSeparator); - } - - List artList = new ArrayList(project.getArtifacts()); - Iterator i = artList.iterator(); - - if (i.hasNext()) { - sb.append(i.next().getFile().getPath()); - - while (i.hasNext()) { - sb.append(File.pathSeparator); - sb.append(i.next().getFile().getPath()); - } - } - - String classpath = sb.toString(); - if(verbose){ - getLog().info(""); - getLog().info("-- Classpath --"); - getLog().info(""); - getLog().info(classpath); - getLog().info(""); - } - return classpath; - } -} Index: hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/AbstractInhabitantsGeneratorMojo.java =================================================================== --- hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/AbstractInhabitantsGeneratorMojo.java (revision 4270) +++ hk2-inhabitant-generator/src/main/java/org/jvnet/hk2/generator/maven/AbstractInhabitantsGeneratorMojo.java (working copy) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -52,13 +52,9 @@ import org.jvnet.hk2.generator.HabitatGenerator; /** - * Calls the generator with maven - * - * @goal generateInhabitants - * @phase process-classes - * @requiresDependencyResolution test + * Abstract Mojo for inhabitant generator */ -public class MavenInhabitantsGenerator extends AbstractMojo { +public abstract class AbstractInhabitantsGeneratorMojo extends AbstractMojo { /** * The maven project. * @@ -67,16 +63,6 @@ protected MavenProject project; /** - * @parameter expression="${project.build.outputDirectory}" - */ - private File outputDirectory; - - /** - * @parameter expression="${project.build.testOutputDirectory}" - */ - private File testOutputDirectory; - - /** * @parameter */ private boolean verbose; @@ -87,19 +73,17 @@ private String locator; /** - * @parameter + * @parameter expression="${supportedProjectTypes}" default-value="jar" */ - private boolean test = false; + private String supportedProjectTypes; /** - * @parameter + * @parameter default-value="${project.build.outputDirectory}" */ - private boolean noswap; + private File buildOutputDirectory; - /** - * @parameter expression="${supportedProjectTypes}" default-value="jar" - */ - private String supportedProjectTypes; + protected abstract boolean getNoSwap(); + protected abstract File getOutputDirectory(); /** * This method will compile the inhabitants file based on @@ -112,25 +96,23 @@ return; } - File output = (test)? testOutputDirectory : outputDirectory; - output.mkdirs(); - - if (!output.exists()) { + getOutputDirectory().mkdirs(); + if (!getOutputDirectory().exists()) { getLog().info("Exiting hk2-inhabitant-generator because could not find output directory " + - output.getAbsolutePath()); + getOutputDirectory().getAbsolutePath()); return; } if (verbose) { getLog().info(""); - getLog().info("hk2-inhabitant-generator generating into location " + output.getAbsolutePath()); + getLog().info("hk2-inhabitant-generator generating into location " + getOutputDirectory().getAbsolutePath()); getLog().info(""); } LinkedList arguments = new LinkedList(); arguments.add(HabitatGenerator.FILE_ARG); - arguments.add(output.getAbsolutePath()); + arguments.add(getOutputDirectory().getAbsolutePath()); if (verbose) { arguments.add(HabitatGenerator.VERBOSE_ARG); @@ -144,28 +126,28 @@ arguments.add(HabitatGenerator.SEARCHPATH_ARG); arguments.add(getBuildClasspath()); - if (noswap) { + if (getNoSwap()) { arguments.add(HabitatGenerator.NOSWAP_ARG); } String argv[] = arguments.toArray(new String[arguments.size()]); int result = HabitatGenerator.embeddedMain(argv); - if (result != 0) { - throw new MojoFailureException("Could not generate inhabitants file for " + - (test ? testOutputDirectory : outputDirectory)); + throw new MojoFailureException("Could not generate inhabitants file for " + getOutputDirectory()); } } private String getBuildClasspath() { StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); - sb.append(File.pathSeparator); - } + sb.append(buildOutputDirectory.getAbsolutePath()); + sb.append(File.pathSeparator); + if (!buildOutputDirectory.equals(getOutputDirectory())) { + sb.append(getOutputDirectory().getAbsolutePath()); + sb.append(File.pathSeparator); + } + List artList = new ArrayList(project.getArtifacts()); Iterator i = artList.iterator(); Index: core/pom.xml =================================================================== --- core/pom.xml (revision 4270) +++ core/pom.xml (working copy) @@ -61,18 +61,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true @@ -94,8 +88,8 @@ - org.glassfish.hk2 - hk2-locator + org.glassfish.hk2 + hk2-locator ${project.parent.version} @@ -104,6 +98,7 @@ ${project.parent.version} + jdk5 Index: config-generator/src/java/org/jvnet/hk2/config/generator/Property.java =================================================================== --- config-generator/src/java/org/jvnet/hk2/config/generator/Property.java (revision 4270) +++ config-generator/src/java/org/jvnet/hk2/config/generator/Property.java (working copy) @@ -1,163 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.jvnet.hk2.config.generator; - -import com.sun.codemodel.JBlock; -import com.sun.codemodel.JExpression; -import com.sun.codemodel.JVar; -import org.jvnet.hk2.config.Attribute; -import org.jvnet.hk2.config.Dom; -import org.jvnet.hk2.config.Element; - -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.TypeMirror; -import java.lang.annotation.Annotation; - -/** - * Represents configurable property of the component. - * - * @author Kohsuke Kawaguchi - */ -abstract class Property { - /** - * Field/method declaration of this property. - * Used to read annotations on this property. - */ - abstract javax.lang.model.element.Element decl(); - - /** - * Name used as a seed for the XML name of this property. - * This is the property name / field name. - */ - String seedName() { - return decl().getSimpleName().toString(); - } - - /** - * The type of the property. - */ - abstract TypeMirror type(); - - abstract void assign(JVar $target, JBlock block, JExpression rhs); - - A getAnnotation(Class a) { - return decl().getAnnotation(a); - } - - private Boolean isKey=null; - - /** - * Does this property have {@link Attribute#key()} or {@link Element#key()}. - */ - final boolean isKey() { - if(isKey==null) - isKey = _isKey(); - return isKey; - } - - private boolean _isKey() { - Element e = getAnnotation(Element.class); - if(e!=null && e.key()) return true; - - Attribute a = getAnnotation(Attribute.class); - return a != null && a.key(); - } - - String inferName(String name) { - if(name.length()==0) - name = Dom.convertName(seedName()); - return name; - } - - /** - * Property that consists of a set/add/get method. - */ - static final class Method extends Property { - final ExecutableElement method; - /** - * True if this property is based on the getter method. False if the setter/adder. - */ - final boolean getter; - - public Method(ExecutableElement method) { - this.method = method; - getter = !method.getReturnType().toString().equals("void"); - } - - javax.lang.model.element.Element decl() { - return method; - } - - TypeMirror type() { - if(getter) - return method.getReturnType(); - else - return method.getParameters().iterator().next().asType(); - } - - void assign(JVar $target, JBlock block, JExpression rhs) { - block.invoke($target, method.getSimpleName().toString()).arg(rhs); - } - } - - /** - * Property that consists of a field. - */ - static final class Field extends Property { - final VariableElement field; - - public Field(VariableElement field) { - this.field = field; - } - - javax.lang.model.element.Element decl() { - return field; - } - - TypeMirror type() { - return field.asType(); - } - - void assign(JVar $target, JBlock block, JExpression rhs) { - block.assign($target.ref(field.getSimpleName().toString()), rhs); - } - } -} Index: config-generator/src/java/org/jvnet/hk2/config/generator/StringUtil.java =================================================================== --- config-generator/src/java/org/jvnet/hk2/config/generator/StringUtil.java (revision 4270) +++ config-generator/src/java/org/jvnet/hk2/config/generator/StringUtil.java (working copy) @@ -1,54 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.jvnet.hk2.config.generator; - -/** - * @author Kohsuke Kawaguchi - */ -final class StringUtil { - static String join(Iterable items, String separator) { - StringBuilder buf = new StringBuilder(); - for (String item : items) { - if(buf.length()>0) buf.append(separator); - buf.append(item); - } - return buf.toString(); - } -} Index: config-generator/src/java/org/jvnet/hk2/config/generator/maven/ConfigGeneratorPlugin.java =================================================================== --- config-generator/src/java/org/jvnet/hk2/config/generator/maven/ConfigGeneratorPlugin.java (revision 4270) +++ config-generator/src/java/org/jvnet/hk2/config/generator/maven/ConfigGeneratorPlugin.java (working copy) @@ -1,246 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.jvnet.hk2.config.generator.maven; - -import java.io.File; -import java.util.*; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; -import org.jvnet.hk2.config.generator.ConfigInjectorGenerator; - -import javax.tools.DiagnosticCollector; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; - -/** - * @author jwells - * - * @goal generateInjectors - * @phase generate-sources - * @requiresDependencyResolution test - */ -public class ConfigGeneratorPlugin extends AbstractMojo { - private final static String GENERATED_SOURCES = "generated-sources/hk2-config-generator/src"; - private final static String MAIN_NAME = "main"; - private final static String TEST_NAME = "test"; - private final static String JAVA_NAME = "java"; - - /** - * The maven project. - * - * @parameter expression="${project}" @required @readonly - */ - protected MavenProject project; - - /** - * @parameter expression="${project.build.directory}" - */ - private File buildDirectory; - - /** - * @parameter expression="${project.build.sourceDirectory}" - */ - private File sourceDirectory; - - /** - * @parameter expression="${project.build.testSourceDirectory}" - */ - private File testSourceDirectory; - - /** - * @parameter expression="${project.build.outputDirectory}" - */ - private File outputDirectory; - - /** - * @parameter - */ - private boolean test; - - /** - * @parameter - */ - private boolean verbose; - - /** - * @parameter expression="${supportedProjectTypes}" default-value="jar" - */ - private String supportedProjectTypes; - - /** - * @parameter expression="${includes}" default-value="**\/*.java" - */ - private String includes; - - /** - * @parameter expression="${excludes}" default-value="" - */ - private String excludes; - - /* (non-Javadoc) - * @see org.apache.maven.plugin.Mojo#execute() - */ - private void internalExecute() throws Throwable { - List projectTypes = Arrays.asList(supportedProjectTypes.split(",")); - File srcDir = (test) ? testSourceDirectory : sourceDirectory; - if(!projectTypes.contains(project.getPackaging()) - || !srcDir.exists() - || !srcDir.isDirectory()){ - return; - } - - // prepare the generated source directory - File generatedSources = new File(buildDirectory, GENERATED_SOURCES); - File phaseGeneratedFile = (test) ? new File(generatedSources, TEST_NAME) : new File(generatedSources, MAIN_NAME); - File javaGeneratedFile = new File(phaseGeneratedFile, JAVA_NAME); - javaGeneratedFile.mkdirs(); - String outputPath = javaGeneratedFile.getAbsolutePath(); - - // prepare command line arguments - List options = new ArrayList(); - options.add("-proc:only"); - options.add("-s"); - options.add(outputPath); - options.add("-d"); - options.add(outputPath); - options.add("-cp"); - options.add(getBuildClasspath()); - List classNames = new ArrayList(); - classNames.addAll(FileUtils.getFileNames(srcDir, includes, excludes,true)); - - if(verbose){ - getLog().info(""); - getLog().info("-- AnnotationProcessing Command Line --"); - getLog().info(""); - getLog().info(options.toString()); - getLog().info(classNames.toString()); - getLog().info(""); - } - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - DiagnosticCollector diagnostics = new DiagnosticCollector(); - StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null); - Iterable compilationUnits = fileManager.getJavaFileObjectsFromStrings(classNames); - JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits); - task.setProcessors(Collections.singleton(new ConfigInjectorGenerator())); - - boolean compilationResult = task.call(); - if(verbose) - getLog().info("Result: " + (compilationResult ? "OK" : "!!! failed !!!")); - - // make the generated source directory visible for compilation - if(test){ - project.addTestCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Test Source directory: " + javaGeneratedFile + " added."); - } - } else { - project.addCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Source directory: " + javaGeneratedFile + " added."); - } - } - } - - /* (non-Javadoc) - * @see org.apache.maven.plugin.Mojo#execute() - */ - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - try { - internalExecute(); - } - catch (Throwable th) { - if (th instanceof MojoExecutionException) { - throw (MojoExecutionException) th; - } - if (th instanceof MojoFailureException) { - throw (MojoFailureException) th; - } - - Throwable cause = th; - int lcv = 0; - while (cause != null) { - getLog().error("Exception from hk2-config-generator[" + lcv++ + "]=" + cause.getMessage()); - cause.printStackTrace(); - - cause = cause.getCause(); - } - - throw new MojoExecutionException(th.getMessage(), th); - } - } - - private String getBuildClasspath() { - StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); - sb.append(File.pathSeparator); - } - - List artList = new ArrayList(project.getArtifacts()); - Iterator i = artList.iterator(); - - if (i.hasNext()) { - sb.append(i.next().getFile().getPath()); - - while (i.hasNext()) { - sb.append(File.pathSeparator); - sb.append(i.next().getFile().getPath()); - } - } - - String classpath = sb.toString(); - if(verbose){ - getLog().info(""); - getLog().info("-- Classpath --"); - getLog().info(""); - getLog().info(classpath); - getLog().info(""); - } - return classpath; - } -} Index: config-generator/src/java/org/jvnet/hk2/config/generator/ConfigInjectorGenerator.java =================================================================== --- config-generator/src/java/org/jvnet/hk2/config/generator/ConfigInjectorGenerator.java (revision 4270) +++ config-generator/src/java/org/jvnet/hk2/config/generator/ConfigInjectorGenerator.java (working copy) @@ -1,1042 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.jvnet.hk2.config.generator; - -import com.sun.codemodel.CodeWriter; -import com.sun.codemodel.JAnnotationUse; -import com.sun.codemodel.JBlock; -import com.sun.codemodel.JClass; -import com.sun.codemodel.JClassAlreadyExistsException; -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import com.sun.codemodel.JExpr; -import com.sun.codemodel.JExpression; -import com.sun.codemodel.JForEach; -import com.sun.codemodel.JInvocation; -import com.sun.codemodel.JMethod; -import com.sun.codemodel.JMod; -import com.sun.codemodel.JPackage; -import com.sun.codemodel.JType; -import com.sun.codemodel.JVar; -import com.sun.enterprise.tools.apt.ContractFinder; -import org.jvnet.hk2.annotations.InhabitantAnnotation; -import org.jvnet.hk2.annotations.Service; -import org.jvnet.hk2.component.MultiMap; -import org.jvnet.hk2.config.Attribute; -import org.jvnet.hk2.config.ConfigBeanProxy; -import org.jvnet.hk2.config.ConfigInjector; -import org.jvnet.hk2.config.ConfigMetadata; -import org.jvnet.hk2.config.Configured; -import org.jvnet.hk2.config.Dom; -import org.jvnet.hk2.config.Element; -import org.jvnet.hk2.config.InjectionTarget; -import org.jvnet.hk2.config.NoopConfigInjector; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Filer; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.MirroredTypeException; -import javax.lang.model.type.NoType; -import javax.lang.model.type.PrimitiveType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.SimpleElementVisitor6; -import javax.lang.model.util.SimpleTypeVisitor6; -import javax.lang.model.util.Types; -import javax.tools.Diagnostic; -import javax.tools.StandardLocation; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; - -import static javax.tools.StandardLocation.CLASS_PATH; -import static javax.tools.StandardLocation.SOURCE_PATH; - -/** - * Generates {@link ConfigInjector} implementations for {@link Configured} objects - * and {@link ConfigBeanProxy} subtypes. - * - * @author Kohsuke Kawaguchi - */ - -public class ConfigInjectorGenerator extends AbstractProcessor { - - private JCodeModel cm; - - private TypeMath math; - /** - * Reference to the {@link ConfigBeanProxy} type. - */ - private TypeElement configBeanProxy; - - private final GeneratorVisitor visitor = new GeneratorVisitor(); - - public ConfigInjectorGenerator() { - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); // to avoid version warnings - } - - @Override - public Set getSupportedAnnotationTypes() { - return Collections.singleton(Configured.class.getName()); - } - - @Override - public synchronized void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - this.math = new TypeMath(processingEnv); - configBeanProxy = processingEnv.getElementUtils().getTypeElement(ConfigBeanProxy.class.getName()); - } - - @Override - public boolean process(Set annotations, RoundEnvironment roundEnv) { - cm = new JCodeModel(); - - for (TypeElement annotation : annotations) { - for(javax.lang.model.element.Element d : roundEnv.getElementsAnnotatedWith(annotation)) - d.accept(visitor, null); - - try { - cm.build(new FilerCodeWriter(processingEnv.getFiler())); - } catch (IOException e) { - throw new Error(e); - } - } - return true; - } - - - private class GeneratorVisitor extends SimpleElementVisitor6 { - - @Override - public Void visitType(TypeElement element, Void aVoid) { - switch (element.getKind()) { - /** - * For each {@link ConfigBeanProxy} annotated with {@link Configured}. - */ - case INTERFACE: { - try { - if(!isSubType(element,configBeanProxy)) { - printError(element.getQualifiedName() + " has @Configured but doesn't extend ConfigBeanProxy", element); - } else - new ClassGenerator(element,true).generate(); - } catch (JClassAlreadyExistsException ex) { - printError(ex.toString(), element); - } - break; - } - /** - * For each class annotated with {@link Configured}. - */ - case CLASS: { - try { - new ClassGenerator(element,false).generate(); - } catch (JClassAlreadyExistsException ex) { - printError(ex.toString(), element); - } - break; - } - } - return null; - } - } - - - - private boolean isSubType(TypeElement subType, TypeElement baseType) { - Types types = processingEnv.getTypeUtils(); - return types.isSubtype(types.getDeclaredType(subType), types.getDeclaredType(baseType)); - } - - /*package*/ class ClassGenerator { - final TypeElement clz; - final JDefinedClass injector; - final JClass targetType; - final JAnnotationUse service; - final JMethod injectMethod,injectAttributeMethod,injectElementMethod; - final MultiMap metadata = new MultiMap(); - /** - * Key property that has {@link Element#key()} or {@link Attribute#key()} - */ - private Property key=null; - - /** - * If true, generate a ConfigInjector that extends from {@link NoopConfigInjector}. - * This is used as the metadata place holder for {@link ConfigBeanProxy}s. - *

- * If false, generate a real {@link ConfigInjector}. - * - *

- * See the test-config test module for this difference in action. - */ - private final boolean generateNoopConfigInjector; - - - public ClassGenerator(TypeElement clz, boolean generateNoopConfigInjector) throws JClassAlreadyExistsException { - this.clz = clz; - this.generateNoopConfigInjector = generateNoopConfigInjector; - Configured c = clz.getAnnotation(Configured.class); - - String name = clz.getQualifiedName().toString(); - targetType = cm.ref(name); - - // [RESULT] - // @Service(name='...') - // @InjectionTarget(target) - // public class XYZInjector extends ConfigInjector - injector = cm._class(name+"Injector"); - String elementName = c.name(); - if(c.local()) { - if(elementName.length()>0) { - printError("@Configured.local and @Configured.name is mutually exclusive", clz); - elementName = ""; // error recovery - } - } else { - if(elementName.length()==0) // infer default - elementName = Dom.convertName(clz.getSimpleName().toString()); - } - - service = injector.annotate(Service.class).param("name",elementName); - injector.annotate(InjectionTarget.class).param("value",targetType); - - Set targetHabitats = new HashSet(); - for (AnnotationMirror am : clz.getAnnotationMirrors()) { - InhabitantAnnotation ia = am.getAnnotationType().asElement().getAnnotation(InhabitantAnnotation.class); - if (ia != null) { - targetHabitats.add(ia.value()); - } - } - - if(generateNoopConfigInjector) { - injector._extends(cm.ref(NoopConfigInjector.class)); - injectAttributeMethod = null; - injectMethod = null; - injectElementMethod = null; - } else { - injector._extends(cm.ref(ConfigInjector.class).narrow(targetType)); - - // [RESULT] - // public void inject(Dom dom, Property target) { ... } - injectMethod = injector.method(JMod.PUBLIC, void.class, "inject"); - injectMethod.param(Dom.class, "dom"); - injectMethod.param(targetType, "target"); - injectMethod.body(); - - injectAttributeMethod = injector.method(JMod.PUBLIC,void.class,"injectAttribute"); - addReinjectionParam(injectAttributeMethod); - - injectElementMethod = injector.method(JMod.PUBLIC,void.class,"injectElement"); - addReinjectionParam(injectElementMethod); - } - - metadata.add(ConfigMetadata.TARGET,name); - - // locate additional contracts for the target. - for (TypeElement t : ContractFinder.find(clz)) - metadata.add(ConfigMetadata.TARGET_CONTRACTS,t.getQualifiedName().toString()); - if (targetHabitats.size() > 0) { - StringBuilder sb = new StringBuilder(); - for (String h : targetHabitats) { - sb.append(h).append(";"); - } - metadata.add(ConfigMetadata.TARGET_HABITATS, sb.toString()); - } - } - - private void addReinjectionParam(JMethod method) { - method.param(Dom.class,"dom"); - method.param(String.class,"name"); - method.param(targetType, "target"); - } - - /** - * Visits all annotated fields/methods and - * generates the body of the {@link ConfigInjector#inject(Dom, Object)} code. - */ - public void generate() { - Stack q = new Stack(); - Set visited = new HashSet(); - q.push(clz); - - while(!q.isEmpty()) { - TypeElement t = q.pop(); - if(!visited.add(t)) continue; // been here already - for (javax.lang.model.element.Element child : t.getEnclosedElements()) { - switch (child.getKind()) { - case FIELD: { // ElementFilter.fieldsIn - generate(new Property.Field((VariableElement) child)); - break; - } - case METHOD: { - generate(new Property.Method((ExecutableElement) child)); - } - } - } - - for (TypeMirror it : clz.getInterfaces()) - q.add((TypeElement) ((DeclaredType)it).asElement()); - - if (ElementKind.CLASS.equals(t.getKind())) { - TypeMirror sc = t.getSuperclass(); - if(!TypeKind.NONE.equals(sc.getKind())) - q.add((TypeElement) ((DeclaredType) sc).asElement()); - } - } - - service.param("metadata", metadata.toCommaSeparatedString()); - } - - private void generate(Property p) { - Attribute a = p.getAnnotation(Attribute.class); - Element e = p.getAnnotation(Element.class); - - if(a!=null) { - new AttributeMethodGenerator(p,a).generate(); - if(e!=null) - printError("Cannot have both @Element and @Attribute at the same time", p.decl()); - } else { - if(e!=null) - new ElementMethodGenerator(p,e).generate(); - } - - // Updates #key with error check. - if(p.isKey()) { - if(key!=null) { - printError("Multiple key properties", p.decl()); - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Another one is at here", key.decl()); - } - key = p; - } - } - - /** - * Generates a single injection method, which inject - * value(s) of a particular element/attribute name. - */ - private abstract class MethodGenerator { - final JBlock body; - final JVar $dom; - final JVar $target; - /** - * Element name or attribute name. - * A special case is "*" for elements that indicate substitute-by-type. - */ - final String xmlName; - final Property p; - private int iota=1; - /** - * Erasure of {@code p.type()} - */ - final TypeMirror erasure; - /** - * If this is a multi-value property, the packer knows how to create a collection value. - */ - final Packer packer; - /** - * The type of individual item. If this is a multi-value property, this is a type of the collection - * item, otherwise the same as {@link #erasure}. - */ - final TypeMirror itemType; - /** - * Converter for {@link #itemType}. - */ - /*semi-final*/ Converter conv; - - MethodGenerator(String methodNamePrefix, JMethod reinjectionMethod, Property p, String xmlName) { - this.xmlName = p.inferName(xmlName); - this.p = p; - - if(generateNoopConfigInjector) { - body = null; - $dom = null; - $target = null; - } else { - JMethod m = injector.method(JMod.PUBLIC,void.class, methodNamePrefix+p.seedName()); - $dom = m.param(Dom.class,"dom"); - $target = m.param(targetType,"target"); - body = m.body(); - - injectMethod.body().invoke(m).arg($dom).arg($target); - - reinjectionMethod.body()._if(JExpr.lit(this.xmlName).invoke("equals").arg(JExpr.ref("name"))) - ._then().invoke(m).arg($dom).arg($target); - } - - erasure = erasure(p.type()); - packer = createPacker(p.type(),erasure); - - itemType = packer==null ? erasure : erasure(packer.itemType()); - } - - private void assign(JExpression rhs) { - p.assign($target,body,rhs); - } - - /** - * Returns '@xmlName' for attributes and '<xmlName>' for elements. - */ - protected abstract String xmlTokenName(); - - protected void generate() { - conv = createConverter(itemType); - conv.addMetadata(xmlTokenName(),itemType); - - if(!isVariableExpansion() && toJtype.visit(itemType,null)!=cm.ref(String.class)) - printError("variableExpansion=false is only allowed on String", p.decl()); - - if(!generateNoopConfigInjector) { - JVar value = var( - packer!=null ? cm.ref(List.class).narrow(conv.sourceType()) : conv.sourceType(),getXmlValue()); - - if(!isRequired()) - body._if(value.eq(JExpr._null()))._then()._return(); - - if(packer!=null) - handleMultiValue(value); - else - assign(conv.as(value,itemType)); - } - - if(p.isKey()) - addKey(); - } - - /** - * Returns true if the property must have a value, or if it's optional. - */ - protected abstract boolean isRequired(); - - /** - * Returns true if the property is a reference to another element - */ - protected abstract boolean isReference(); - - /** - * Returns true if the property is a a subject of variable expansion. - */ - protected abstract boolean isVariableExpansion(); - - /** - * Return true if this property is {@code @FromElement("*")}, - * which means finding a match by types - */ - protected abstract boolean isAllElementMatch(); - - /** - * Obtains the source value(s) from {@link Dom}. - */ - protected abstract JExpression getXmlValue(); - - private void addKey() { - metadata.add(ConfigMetadata.KEY, xmlTokenName()); - metadata.add(ConfigMetadata.KEYED_AS, ((TypeElement) p.decl().getEnclosingElement()).getQualifiedName().toString()); - } - - /** - * Invokes a method on DOM by adjusting the name for plural. - */ - final JInvocation invokeDom(String methodName) { - if(packer!=null) methodName+='s'; - return $dom.invoke(methodName); - } - - private void handleMultiValue(JVar values) { - // [RESULT] - // List values = dom.leafElements("..."); - // - // for( S v : values ) { - // ((v)); - // } - // ... assign ... - packer.start(values.invoke("size")); - JForEach forEach = body.forEach(conv.sourceType(), id(), values); - packer.pack(forEach.body(),conv.as(forEach.var(),packer.itemType()), forEach.var()); - assign(packer.end()); - } - - /** - * Creates a variable - */ - protected JVar var(JType t, JExpression init) { - return body.decl(t,id(),init); - } - - protected JVar var(Class t, JExpression init) { - return var(cm.ref(t),init); - } - - /** - * Creates an unique id. - */ - private String id() { - return "v"+(iota++); - } - - private Packer createPacker(TypeMirror type, TypeMirror erasure) { - if(erasure instanceof ArrayType) { - // T=X[] - return new ArrayPacker((ArrayType)erasure); - } - - TypeMirror itemType = math.isCollection(type); - if(itemType!=null) { - // T=Collection[] - return new ListPacker(type,itemType); - } - - TypeMirror mapType = math.baseClassFinder.visit(type, processingEnv.getElementUtils().getTypeElement(Map.class.getName())); - if(mapType!=null) { - // T=Map<...> - DeclaredType d = (DeclaredType)mapType; - List itr = d.getTypeArguments(); - return new MapPacker(itr.get(1)); - } - - return null; - } - - abstract class Packer { - abstract TypeMirror itemType(); - /** - * Starts packing. - */ - abstract void start(JExpression $valueSize); - /** - * Adds one more item to the pack. - */ - abstract void pack(JBlock block, JExpression item, JExpression sourceValue); - - /** - * Returns the packed value to be set. - */ - abstract JExpression end(); - } - - final class ArrayPacker extends Packer { - private JVar $array,$index; - private final JType arrayT; - private final JType componentT; - private final ArrayType at; - - public ArrayPacker(ArrayType t) { - this.at = t; - this.componentT = toJtype.visit(itemType(), null); - this.arrayT = componentT.array(); - } - - TypeMirror itemType() { - return at.getComponentType(); - } - - void start(JExpression $valueSize) { - // [RESULT] - // T[] x = new T[values.size()]; - $array = var(arrayT, JExpr.newArray(componentT, $valueSize)); - $index = var(int.class,JExpr.lit(0)); - } - - void pack(JBlock block, JExpression item, JExpression sourceValue) { - // [RESULT] - // x[i++] = ; - block.assign($array.component($index.incr()),item); - } - - JExpression end() { - return $array; - } - } - - final class ListPacker extends Packer { - private JVar $list; - private final JClass collectionType,itemType; - private final TypeMirror itemT; - - public ListPacker(TypeMirror collectionType, TypeMirror itemType) { - this.collectionType = toJtype.visit(collectionType, null).boxify(); - this.itemType = toJtype.visit(itemType, null).boxify(); - this.itemT = itemType; - } - - TypeMirror itemType() { - return itemT; - } - - void start(JExpression $valueSize) { - // [RESULT] - // T x = new ArrayList(values.size()); - $list = var(collectionType,JExpr._new(implType()).arg($valueSize)); - } - - /** - * Figure out the concrete implementation class to be used. - */ - JType implType() { - if(cm.ref(Set.class).isAssignableFrom(collectionType)) - return cm.ref(HashSet.class).narrow(itemType); - return cm.ref(ArrayList.class).narrow(itemType); - } - - void pack(JBlock block, JExpression item, JExpression sourceValue) { - // [RESULT] - // x.add(); - block.invoke($list,"add").arg(item); - } - - JExpression end() { - return $list; - } - } - - final class MapPacker extends Packer { - private JVar $map; - private final TypeMirror itemT; - - public MapPacker(TypeMirror itemType) { - this.itemT = itemType; - } - - TypeMirror itemType() { - return itemT; - } - - void start(JExpression $valueSize) { - // [RESULT] - // T x = new HashMap(); - $map = var(Map.class,JExpr._new(cm.ref(HashMap.class)).arg($valueSize)); - } - - void pack(JBlock block, JExpression item, JExpression itemDom) { - // [RESULT] - // x.put(dom.getKey(),); - block.invoke($map,"put").arg(itemDom.invoke("getKey")).arg(item); - } - - JExpression end() { - return $map; - } - } - - private Converter createConverter(TypeMirror itemType) { - try { - // is this a leaf value? - math.simpleValueConverter.visit(itemType, JExpr._null()); - return new LeafConverter(); - } catch (UnsupportedOperationException e) { - // nope - } - - // try to handle it as a reference - if (TypeKind.DECLARED.equals(itemType.getKind())) { - TypeElement decl = (TypeElement) ((DeclaredType)itemType).asElement(); - Configured cfg = decl.getAnnotation(Configured.class); - if(cfg!=null) { - // node value - if(isReference()) - return new ReferenceConverter(); - else - return new NodeConverter(); - } - } - - if(isAllElementMatch()) { - return new NodeByTypeConverter(itemType); - } - - printError("I don't know how to inject "+itemType+" from configuration", p.decl()); - return new NodeConverter(); // error recovery - } - - /** - * Encapsulates the source value representation in {@link Dom}. - */ - abstract class Converter { - /** - * Generates an expression that converts 'rhs'. - * - * @param targetType - * The expected type of the expression, so that the generated expression - * can contain cast operation if necessary. - */ - abstract JExpression as(JExpression rhs, TypeMirror targetType); - /** - * Source value type as returned by {@link Dom}. - */ - abstract JClass sourceType(); - - /** - * True if the XML representation of the source value is a leaf (string value) - * as opposed to node (an XML fragment.) - */ - abstract boolean isLeaf(); - - abstract void addMetadata(String key,TypeMirror itemType); - - protected final String makeCollectionIfNecessary(String s) { - if(packer!=null) return "collection:"+s; - else return s; - } - } - - class LeafConverter extends Converter { - JExpression as(JExpression rhs, TypeMirror targetType) { - return math.simpleValueConverter.visit(targetType, rhs); - } - JClass sourceType() { - return cm.ref(String.class); - } - - boolean isLeaf() { - return true; - } - - void addMetadata(String key,TypeMirror itemType) { - metadata.add(key,makeCollectionIfNecessary("leaf")); - } - } - - class NodeConverter extends Converter { - JExpression as(JExpression rhs, TypeMirror targetType) { - return JExpr.cast(toJtype.visit(targetType, null), rhs.invoke("get")); - } - JClass sourceType() { - return cm.ref(Dom.class); - } - - boolean isLeaf() { - return false; - } - - void addMetadata(String key,TypeMirror itemType) { - metadata.add(key,makeCollectionIfNecessary(itemType.toString())); - } - } - - class NodeByTypeConverter extends Converter { - final JClass sourceType; - - NodeByTypeConverter(TypeMirror sourceType) { - this.sourceType = toJtype.visit(sourceType, null).boxify(); - } - - JExpression as(JExpression rhs, TypeMirror targetType) { - return rhs; - } - JClass sourceType() { - return sourceType; - } - boolean isLeaf() { - return false; - } - void addMetadata(String key,TypeMirror itemType) { - // TODO: we need to indicate that there's open-ended match here - } - } - - class ReferenceConverter extends Converter { - JExpression as(JExpression rhs, TypeMirror targetType) { - return JExpr.invoke("reference").arg($dom).arg(rhs).arg(toJtype.visit(targetType, null).boxify().dotclass()); - } - JClass sourceType() { - return cm.ref(String.class); - } - - boolean isLeaf() { - return true; - } - - void addMetadata(String key,TypeMirror itemType) { - metadata.add(key,makeCollectionIfNecessary("leaf")); - metadata.add(key, "reference"); - } - } - } - - - private final class AttributeMethodGenerator extends MethodGenerator { - private final Attribute a; - - private AttributeMethodGenerator(Property p, Attribute a) { - super("attribute_", injectAttributeMethod, p, a.value()); - this.a = a; - } - - protected String xmlTokenName() { - return '@'+xmlName; - } - - protected boolean isRequired() { - return a.required(); - } - - protected boolean isReference() { - return a.reference(); - } - - protected boolean isVariableExpansion() { - return a.variableExpansion(); - } - - protected boolean isAllElementMatch() { - return false; - } - - protected boolean hasDefault() { - boolean noDefaultValue = - a.defaultValue().length() == 1 && a.defaultValue().charAt(0) == '\u0000'; - return (!noDefaultValue); - } - /** - * Generates the injector that reads an attribute and sets the value. - */ - @Override - protected void generate() { - metadata.add(xmlTokenName(),isRequired()?"required":"optional"); - if (this.hasDefault()) { - if (a.defaultValue().indexOf(',')!=-1) { - metadata.add(xmlTokenName(), '"' + "default:" + a.defaultValue() + '"'); - } else { - metadata.add(xmlTokenName(), "default:" + a.defaultValue()); - } - } - String ant = ""; - try { - a.dataType(); - } catch(MirroredTypeException me) { //hack? - ant = getCanonicalTypeFrom(me); - } - if (ant.length() == 0) { //take it from the return type of method - Property.Method m = (Property.Method)p; // Method needn't be Property's inner class - String typeReturnedByMethodDecl = m.method.getReturnType().toString(); - metadata.add(xmlTokenName(), "datatype:" + typeReturnedByMethodDecl); - } else { - metadata.add(xmlTokenName(), "datatype:" + ant); - } - super.generate(); - } - - protected JExpression getXmlValue() { - if(!isVariableExpansion() && packer!=null) { - printError("collection attribute property is inconsistent with variableExpansion=false", p.decl()); - } - return invokeDom(isVariableExpansion()?"attribute":"rawAttribute").arg(xmlName); - } - } - - private final class ElementMethodGenerator extends MethodGenerator { - private final Element e; - private ElementMethodGenerator(Property p, Element e) { - super("element_", injectElementMethod, p, e.value()); - this.e = e; - } - - protected String xmlTokenName() { - return '<'+xmlName+'>'; - } - - protected JExpression getXmlValue() { - String name; - if(conv.isLeaf()) { - if(isVariableExpansion()) - name = "leafElement"; - else - name = "rawLeafElement"; - } else { - assert isVariableExpansion(); // this error is checked earlier. - if(xmlName.equals("*")) { - return invokeDom("nodeByTypeElement").arg(toJtype.visit(itemType, null).boxify().dotclass()); - } else - name = "nodeElement"; - } - - return invokeDom(name).arg(xmlName); - } - - @Override - protected void generate() { - super.generate(); - if (packer==null) { - for (AnnotationMirror am : p.decl().getAnnotationMirrors()) { - if (!am.toString().contains("hk2")) - metadata.add(xmlTokenName(), am.toString()); - } - } - } - - protected boolean isRequired() { - return e.required(); - } - - protected boolean isReference() { - return e.reference(); - } - - protected boolean isVariableExpansion() { - return e.variableExpansion(); - } - - protected boolean isAllElementMatch() { - return e.value().equals("*"); - } - } - } - - private static String getCanonicalTypeFrom(MirroredTypeException me) { - TypeMirror tm = me.getTypeMirror(); - if (tm instanceof DeclaredType) { - DeclaredType dec = (DeclaredType) tm; - return ((TypeElement)dec.asElement()).getQualifiedName().toString(); - } - return ""; //ok? - } - - private TypeMirror erasure(TypeMirror type) { - return processingEnv.getTypeUtils().erasure(type); - } - - /** - * Takes {@link TypeMirror} and returns the corresponding {@link JType}. - */ - final SimpleTypeVisitor6 toJtype = new SimpleTypeVisitor6() { - - @Override - public JType visitPrimitive(PrimitiveType type, Void param) { - switch (type.getKind()) { - case BOOLEAN: return cm.BOOLEAN; - case BYTE: return cm.BYTE; - case CHAR: return cm.CHAR; - case DOUBLE: return cm.DOUBLE; - case FLOAT: return cm.FLOAT; - case INT: return cm.INT; - case LONG: return cm.LONG; - case SHORT: return cm.SHORT; - } - throw new AssertionError(); - } - - @Override - public JType visitArray(ArrayType type, Void param) { - return visit(type.getComponentType(), null).array(); - } - - @Override - public JType visitDeclared(DeclaredType type, Void param) { - // TODO: generics support - return cm.ref(((TypeElement) type.asElement()).getQualifiedName().toString()); - } - - @Override - protected JType defaultAction(TypeMirror e, Void aVoid) { - throw new UnsupportedOperationException(); - } - - @Override - public JType visitNoType(NoType t, Void aVoid) { - return cm.VOID; - } - }; - - private void printError(String error, javax.lang.model.element.Element element) { - processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, error, element); - } - - /** - * {@link CodeWriter} that generates source code to {@link Filer}. - * - * @author Kohsuke Kawaguchi - * - * Moved from jaxb-xjc to break unneeded dependency. - */ - public static final class FilerCodeWriter extends CodeWriter { - - private final Filer filer; - - public FilerCodeWriter(Filer filer) { - this.filer = filer; - } - - public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { - StandardLocation loc; - if(fileName.endsWith(".java")) { - // Annotation Processing doesn't do the proper Unicode escaping on Java source files, - // so we can't rely on Filer.createSourceFile. - loc = SOURCE_PATH; - } else { - // put non-Java files directly to the output folder - loc = CLASS_PATH; - } - return filer.createResource(loc, pkg.name(), fileName).openOutputStream(); - } - - public Writer openSource(JPackage pkg, String fileName) throws IOException { - String name; - if(pkg.isUnnamed()) - name = fileName; - else - name = pkg.name()+'.'+fileName; - - name = name.substring(0,name.length()-5); // strip ".java" - - return filer.createSourceFile(name).openWriter(); - } - - public void close() {} - } - -} Index: config-generator/src/java/org/jvnet/hk2/config/generator/TypeMath.java =================================================================== --- config-generator/src/java/org/jvnet/hk2/config/generator/TypeMath.java (revision 4270) +++ config-generator/src/java/org/jvnet/hk2/config/generator/TypeMath.java (working copy) @@ -1,165 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ -package org.jvnet.hk2.config.generator; - -import com.sun.codemodel.JExpr; -import com.sun.codemodel.JExpression; - -import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.TypeParameterElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.PrimitiveType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.TypeVariable; -import javax.lang.model.type.WildcardType; -import javax.lang.model.util.SimpleTypeVisitor6; -import java.util.Collection; - -/** - * Defines several type arithemetic operations. - * @author Kohsuke Kawaguchi - */ -class TypeMath { - - protected final ProcessingEnvironment env; - - /** - * Given a declaration X and mirror Y, finds the parametrization of Z=X<...> such that - * Y is assignable to Z. - */ - final SimpleTypeVisitor6 baseClassFinder = new SimpleTypeVisitor6() { - - @Override - public TypeMirror visitDeclared(DeclaredType t, TypeElement sup) { - - TypeMirror r = onDeclaredType(t, sup); - if (r != null) return r; - - Element e = t.asElement(); - switch (e.getKind()) { - case CLASS: { - // otherwise recursively apply super class and base types - TypeMirror sc = ((TypeElement) e).getSuperclass(); - if (!TypeKind.NONE.equals(sc.getKind())) - r = visitDeclared((DeclaredType) sc, sup); - if (r != null) return r; - } - } - return null; - } - - @Override - protected TypeMirror defaultAction(TypeMirror e, TypeElement typeElement) { - return null; - } - - private TypeMirror onDeclaredType(DeclaredType t, TypeElement sup) { - // t = sup<...> - if (t.asElement().equals(sup)) - return t; - - for (TypeMirror i : env.getTypeUtils().directSupertypes(t)) { - TypeMirror r = visitDeclared((DeclaredType) i, sup); - if (r != null) return r; - } - - return null; - } - - @Override - public TypeMirror visitTypeVariable(TypeVariable t, TypeElement sup) { - // we are checking if T (declared as T extends A&B&C) is assignable to sup. - // so apply bounds recursively. - for (TypeMirror r : ((TypeParameterElement) t.asElement()).getBounds()) { - TypeMirror m = visit(r, sup); - if (m != null) return m; - } - return null; - } - - @Override - public TypeMirror visitWildcard(WildcardType type, TypeElement sup) { - // we are checking if T (= ? extends A&B&C) is assignable to sup. - // so apply bounds recursively. - return visit(type.getExtendsBound(), sup); - } - }; - /** - * Adapts the string expression into the expression of the given type. - */ - final SimpleTypeVisitor6 simpleValueConverter = new SimpleTypeVisitor6() { - - @Override - public JExpression visitPrimitive(PrimitiveType type, JExpression param) { - String kind = type.getKind().toString(); - return JExpr.invoke("as" + kind.charAt(0) + kind.substring(1).toLowerCase()).arg(param); - } - - @Override - public JExpression visitDeclared(DeclaredType type, JExpression param) { - String qn = ((TypeElement) type.asElement()).getQualifiedName().toString(); - if (qn.equals("java.lang.String")) - return param; // no conversion needed for string - // return JExpr.invoke("as"+type.getDeclaration().getSimpleName()).arg(param); - throw new UnsupportedOperationException(); - } - - @Override - protected JExpression defaultAction(TypeMirror e, JExpression jExpression) { - throw new UnsupportedOperationException(); - } - }; - - public TypeMath(ProcessingEnvironment env) { - this.env = env; - } - - TypeMirror isCollection(TypeMirror t) { - TypeMirror collectionType = baseClassFinder.visit(t, env.getElementUtils().getTypeElement(Collection.class.getName())); - if (collectionType != null) { - DeclaredType d = (DeclaredType) collectionType; - return d.getTypeArguments().iterator().next(); - } else - return null; - } -} Index: config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/ConfigGeneratorMojo.java =================================================================== --- config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/ConfigGeneratorMojo.java (revision 0) +++ config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/ConfigGeneratorMojo.java (working copy) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -40,207 +40,43 @@ package org.jvnet.hk2.config.generator.maven; import java.io.File; -import java.util.*; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; -import org.jvnet.hk2.config.generator.ConfigInjectorGenerator; -import javax.tools.DiagnosticCollector; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; - /** - * @author jwells - * - * @goal generateInjectors + * @goal generate-injectors * @phase generate-sources * @requiresDependencyResolution test */ -public class ConfigGeneratorPlugin extends AbstractMojo { - private final static String GENERATED_SOURCES = "generated-sources/hk2-config-generator/src"; - private final static String MAIN_NAME = "main"; - private final static String TEST_NAME = "test"; - private final static String JAVA_NAME = "java"; - - /** - * The maven project. - * - * @parameter expression="${project}" @required @readonly - */ - protected MavenProject project; +public class ConfigGeneratorMojo extends AbstractConfigGeneratorMojo { /** - * @parameter expression="${project.build.directory}" - */ - private File buildDirectory; - - /** - * @parameter expression="${project.build.sourceDirectory}" - */ - private File sourceDirectory; - - /** - * @parameter expression="${project.build.testSourceDirectory}" - */ - private File testSourceDirectory; - - /** * @parameter expression="${project.build.outputDirectory}" */ private File outputDirectory; /** - * @parameter + * @parameter expression="${project.build.sourceDirectory}" */ - private boolean test; - - /** - * @parameter - */ - private boolean verbose; - - /** - * @parameter expression="${supportedProjectTypes}" default-value="jar" - */ - private String supportedProjectTypes; - - /** - * @parameter expression="${includes}" default-value="**\/*.java" - */ - private String includes; - - /** - * @parameter expression="${excludes}" default-value="" - */ - private String excludes; - - /* (non-Javadoc) - * @see org.apache.maven.plugin.Mojo#execute() - */ - private void internalExecute() throws Throwable { - List projectTypes = Arrays.asList(supportedProjectTypes.split(",")); - File srcDir = (test) ? testSourceDirectory : sourceDirectory; - if(!projectTypes.contains(project.getPackaging()) - || !srcDir.exists() - || !srcDir.isDirectory()){ - return; - } - - // prepare the generated source directory - File generatedSources = new File(buildDirectory, GENERATED_SOURCES); - File phaseGeneratedFile = (test) ? new File(generatedSources, TEST_NAME) : new File(generatedSources, MAIN_NAME); - File javaGeneratedFile = new File(phaseGeneratedFile, JAVA_NAME); - javaGeneratedFile.mkdirs(); - String outputPath = javaGeneratedFile.getAbsolutePath(); + private File sourceDirectory; - // prepare command line arguments - List options = new ArrayList(); - options.add("-proc:only"); - options.add("-s"); - options.add(outputPath); - options.add("-d"); - options.add(outputPath); - options.add("-cp"); - options.add(getBuildClasspath()); - List classNames = new ArrayList(); - classNames.addAll(FileUtils.getFileNames(srcDir, includes, excludes,true)); - - if(verbose){ - getLog().info(""); - getLog().info("-- AnnotationProcessing Command Line --"); - getLog().info(""); - getLog().info(options.toString()); - getLog().info(classNames.toString()); - getLog().info(""); - } - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - DiagnosticCollector diagnostics = new DiagnosticCollector(); - StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null); - Iterable compilationUnits = fileManager.getJavaFileObjectsFromStrings(classNames); - JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits); - task.setProcessors(Collections.singleton(new ConfigInjectorGenerator())); - - boolean compilationResult = task.call(); - if(verbose) - getLog().info("Result: " + (compilationResult ? "OK" : "!!! failed !!!")); - - // make the generated source directory visible for compilation - if(test){ - project.addTestCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Test Source directory: " + javaGeneratedFile + " added."); - } - } else { - project.addCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Source directory: " + javaGeneratedFile + " added."); - } - } + private static String generatedDirectory; + static { + StringBuilder sb = new StringBuilder(); + sb.append(GENERATED_SOURCES).append(File.separatorChar).append(MAIN_NAME).append(File.separatorChar).append(JAVA_NAME); + generatedDirectory = sb.toString(); } + + @Override + protected File getSourceDirectory() { + return sourceDirectory; + } - /* (non-Javadoc) - * @see org.apache.maven.plugin.Mojo#execute() - */ @Override - public void execute() throws MojoExecutionException, MojoFailureException { - try { - internalExecute(); - } - catch (Throwable th) { - if (th instanceof MojoExecutionException) { - throw (MojoExecutionException) th; - } - if (th instanceof MojoFailureException) { - throw (MojoFailureException) th; - } - - Throwable cause = th; - int lcv = 0; - while (cause != null) { - getLog().error("Exception from hk2-config-generator[" + lcv++ + "]=" + cause.getMessage()); - cause.printStackTrace(); - - cause = cause.getCause(); - } - - throw new MojoExecutionException(th.getMessage(), th); - } + protected File getGeneratedDirectory() { + return new File(project.getBuild().getDirectory(),generatedDirectory); } - - private String getBuildClasspath() { - StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); - sb.append(File.pathSeparator); - } - - List artList = new ArrayList(project.getArtifacts()); - Iterator i = artList.iterator(); - - if (i.hasNext()) { - sb.append(i.next().getFile().getPath()); - while (i.hasNext()) { - sb.append(File.pathSeparator); - sb.append(i.next().getFile().getPath()); - } - } - - String classpath = sb.toString(); - if(verbose){ - getLog().info(""); - getLog().info("-- Classpath --"); - getLog().info(""); - getLog().info(classpath); - getLog().info(""); - } - return classpath; + @Override + protected File getOutputDirectory() { + return outputDirectory; } } Index: config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/TestConfigGeneratorMojo.java =================================================================== --- config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/TestConfigGeneratorMojo.java (revision 0) +++ config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/TestConfigGeneratorMojo.java (working copy) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -40,207 +40,43 @@ package org.jvnet.hk2.config.generator.maven; import java.io.File; -import java.util.*; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; -import org.jvnet.hk2.config.generator.ConfigInjectorGenerator; -import javax.tools.DiagnosticCollector; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; - /** - * @author jwells - * - * @goal generateInjectors - * @phase generate-sources + * @goal generate-test-injectors + * @phase generate-test-sources * @requiresDependencyResolution test */ -public class ConfigGeneratorPlugin extends AbstractMojo { - private final static String GENERATED_SOURCES = "generated-sources/hk2-config-generator/src"; - private final static String MAIN_NAME = "main"; - private final static String TEST_NAME = "test"; - private final static String JAVA_NAME = "java"; - - /** - * The maven project. - * - * @parameter expression="${project}" @required @readonly - */ - protected MavenProject project; +public class TestConfigGeneratorMojo extends AbstractConfigGeneratorMojo { /** - * @parameter expression="${project.build.directory}" + * @parameter expression="${project.build.testOutputDirectory}" */ - private File buildDirectory; + private File outputDirectory; /** - * @parameter expression="${project.build.sourceDirectory}" - */ - private File sourceDirectory; - - /** * @parameter expression="${project.build.testSourceDirectory}" */ - private File testSourceDirectory; - - /** - * @parameter expression="${project.build.outputDirectory}" - */ - private File outputDirectory; - - /** - * @parameter - */ - private boolean test; - - /** - * @parameter - */ - private boolean verbose; - - /** - * @parameter expression="${supportedProjectTypes}" default-value="jar" - */ - private String supportedProjectTypes; - - /** - * @parameter expression="${includes}" default-value="**\/*.java" - */ - private String includes; - - /** - * @parameter expression="${excludes}" default-value="" - */ - private String excludes; - - /* (non-Javadoc) - * @see org.apache.maven.plugin.Mojo#execute() - */ - private void internalExecute() throws Throwable { - List projectTypes = Arrays.asList(supportedProjectTypes.split(",")); - File srcDir = (test) ? testSourceDirectory : sourceDirectory; - if(!projectTypes.contains(project.getPackaging()) - || !srcDir.exists() - || !srcDir.isDirectory()){ - return; - } - - // prepare the generated source directory - File generatedSources = new File(buildDirectory, GENERATED_SOURCES); - File phaseGeneratedFile = (test) ? new File(generatedSources, TEST_NAME) : new File(generatedSources, MAIN_NAME); - File javaGeneratedFile = new File(phaseGeneratedFile, JAVA_NAME); - javaGeneratedFile.mkdirs(); - String outputPath = javaGeneratedFile.getAbsolutePath(); + private File sourceDirectory; - // prepare command line arguments - List options = new ArrayList(); - options.add("-proc:only"); - options.add("-s"); - options.add(outputPath); - options.add("-d"); - options.add(outputPath); - options.add("-cp"); - options.add(getBuildClasspath()); - List classNames = new ArrayList(); - classNames.addAll(FileUtils.getFileNames(srcDir, includes, excludes,true)); - - if(verbose){ - getLog().info(""); - getLog().info("-- AnnotationProcessing Command Line --"); - getLog().info(""); - getLog().info(options.toString()); - getLog().info(classNames.toString()); - getLog().info(""); - } - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - DiagnosticCollector diagnostics = new DiagnosticCollector(); - StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null); - Iterable compilationUnits = fileManager.getJavaFileObjectsFromStrings(classNames); - JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits); - task.setProcessors(Collections.singleton(new ConfigInjectorGenerator())); - - boolean compilationResult = task.call(); - if(verbose) - getLog().info("Result: " + (compilationResult ? "OK" : "!!! failed !!!")); - - // make the generated source directory visible for compilation - if(test){ - project.addTestCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Test Source directory: " + javaGeneratedFile + " added."); - } - } else { - project.addCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Source directory: " + javaGeneratedFile + " added."); - } - } + private static String generatedDirectory; + static { + StringBuilder sb = new StringBuilder(); + sb.append(GENERATED_SOURCES).append(File.separatorChar).append(TEST_NAME).append(File.separatorChar).append(JAVA_NAME); + generatedDirectory = sb.toString(); } + + @Override + protected File getSourceDirectory() { + return sourceDirectory; + } - /* (non-Javadoc) - * @see org.apache.maven.plugin.Mojo#execute() - */ @Override - public void execute() throws MojoExecutionException, MojoFailureException { - try { - internalExecute(); - } - catch (Throwable th) { - if (th instanceof MojoExecutionException) { - throw (MojoExecutionException) th; - } - if (th instanceof MojoFailureException) { - throw (MojoFailureException) th; - } - - Throwable cause = th; - int lcv = 0; - while (cause != null) { - getLog().error("Exception from hk2-config-generator[" + lcv++ + "]=" + cause.getMessage()); - cause.printStackTrace(); - - cause = cause.getCause(); - } - - throw new MojoExecutionException(th.getMessage(), th); - } + protected File getGeneratedDirectory() { + return new File(project.getBuild().getDirectory(),generatedDirectory); } - - private String getBuildClasspath() { - StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); - sb.append(File.pathSeparator); - } - - List artList = new ArrayList(project.getArtifacts()); - Iterator i = artList.iterator(); - - if (i.hasNext()) { - sb.append(i.next().getFile().getPath()); - while (i.hasNext()) { - sb.append(File.pathSeparator); - sb.append(i.next().getFile().getPath()); - } - } - - String classpath = sb.toString(); - if(verbose){ - getLog().info(""); - getLog().info("-- Classpath --"); - getLog().info(""); - getLog().info(classpath); - getLog().info(""); - } - return classpath; + @Override + protected File getOutputDirectory() { + return outputDirectory; } } Index: config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/AbstractConfigGeneratorMojo.java =================================================================== --- config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/AbstractConfigGeneratorMojo.java (revision 0) +++ config-generator/src/main/java/org/jvnet/hk2/config/generator/maven/AbstractConfigGeneratorMojo.java (working copy) @@ -41,6 +41,11 @@ import java.io.File; import java.util.*; +import javax.tools.DiagnosticCollector; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -49,24 +54,16 @@ import org.codehaus.plexus.util.FileUtils; import org.jvnet.hk2.config.generator.ConfigInjectorGenerator; -import javax.tools.DiagnosticCollector; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; - /** * @author jwells * - * @goal generateInjectors - * @phase generate-sources - * @requiresDependencyResolution test + * Abstract Mojo for config generator */ -public class ConfigGeneratorPlugin extends AbstractMojo { - private final static String GENERATED_SOURCES = "generated-sources/hk2-config-generator/src"; - private final static String MAIN_NAME = "main"; - private final static String TEST_NAME = "test"; - private final static String JAVA_NAME = "java"; +public abstract class AbstractConfigGeneratorMojo extends AbstractMojo { + protected final static String GENERATED_SOURCES = "generated-sources/hk2-config-generator/src"; + protected final static String MAIN_NAME = "main"; + protected final static String TEST_NAME = "test"; + protected final static String JAVA_NAME = "java"; /** * The maven project. @@ -76,33 +73,8 @@ protected MavenProject project; /** - * @parameter expression="${project.build.directory}" - */ - private File buildDirectory; - - /** - * @parameter expression="${project.build.sourceDirectory}" - */ - private File sourceDirectory; - - /** - * @parameter expression="${project.build.testSourceDirectory}" - */ - private File testSourceDirectory; - - /** - * @parameter expression="${project.build.outputDirectory}" - */ - private File outputDirectory; - - /** * @parameter */ - private boolean test; - - /** - * @parameter - */ private boolean verbose; /** @@ -120,24 +92,28 @@ */ private String excludes; + /** + * @parameter default-value="${project.build.outputDirectory}" + */ + private File buildOutputDirectory; + + protected abstract File getSourceDirectory(); + protected abstract File getGeneratedDirectory(); + protected abstract File getOutputDirectory(); + /* (non-Javadoc) * @see org.apache.maven.plugin.Mojo#execute() */ private void internalExecute() throws Throwable { List projectTypes = Arrays.asList(supportedProjectTypes.split(",")); - File srcDir = (test) ? testSourceDirectory : sourceDirectory; if(!projectTypes.contains(project.getPackaging()) - || !srcDir.exists() - || !srcDir.isDirectory()){ + || !getSourceDirectory().exists() + || !getSourceDirectory().isDirectory()){ return; } - // prepare the generated source directory - File generatedSources = new File(buildDirectory, GENERATED_SOURCES); - File phaseGeneratedFile = (test) ? new File(generatedSources, TEST_NAME) : new File(generatedSources, MAIN_NAME); - File javaGeneratedFile = new File(phaseGeneratedFile, JAVA_NAME); - javaGeneratedFile.mkdirs(); - String outputPath = javaGeneratedFile.getAbsolutePath(); + getGeneratedDirectory().mkdirs(); + String outputPath = getGeneratedDirectory().getAbsolutePath(); // prepare command line arguments List options = new ArrayList(); @@ -149,7 +125,7 @@ options.add("-cp"); options.add(getBuildClasspath()); List classNames = new ArrayList(); - classNames.addAll(FileUtils.getFileNames(srcDir, includes, excludes,true)); + classNames.addAll(FileUtils.getFileNames(getSourceDirectory(), includes, excludes,true)); if(verbose){ getLog().info(""); @@ -167,20 +143,14 @@ task.setProcessors(Collections.singleton(new ConfigInjectorGenerator())); boolean compilationResult = task.call(); - if(verbose) + if(verbose) { getLog().info("Result: " + (compilationResult ? "OK" : "!!! failed !!!")); + } // make the generated source directory visible for compilation - if(test){ - project.addTestCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Test Source directory: " + javaGeneratedFile + " added."); - } - } else { - project.addCompileSourceRoot(outputPath); - if (getLog().isInfoEnabled()) { - getLog().info("Source directory: " + javaGeneratedFile + " added."); - } + project.addCompileSourceRoot(outputPath); + if (getLog().isInfoEnabled()) { + getLog().info("Source directory: " + outputPath + " added."); } } @@ -215,11 +185,13 @@ private String getBuildClasspath() { StringBuilder sb = new StringBuilder(); - // Make sure to add in the directory that has been built - if (test) { - sb.append(outputDirectory.getAbsolutePath()); + + sb.append(buildOutputDirectory.getAbsolutePath()); + sb.append(File.pathSeparator); + if (!buildOutputDirectory.equals(getOutputDirectory())) { + sb.append(getOutputDirectory().getAbsolutePath()); sb.append(File.pathSeparator); - } + } List artList = new ArrayList(project.getArtifacts()); Iterator i = artList.iterator(); Index: config-generator/pom.xml =================================================================== --- config-generator/pom.xml (revision 4270) +++ config-generator/pom.xml (working copy) @@ -53,11 +53,6 @@ config-generator HK2 configuration reader generator module maven-plugin - - - src/java - test/java - @@ -92,14 +87,4 @@ 2.6 - - Index: pom.xml =================================================================== --- pom.xml (revision 4270) +++ pom.xml (working copy) @@ -249,6 +249,11 @@ 2.9 + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + org.apache.felix maven-bundle-plugin 2.3.4 Index: hk2-testing/hk2-junitrunner/pom.xml =================================================================== --- hk2-testing/hk2-junitrunner/pom.xml (revision 4270) +++ hk2-testing/hk2-junitrunner/pom.xml (working copy) @@ -65,12 +65,7 @@ org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: hk2-runlevel/pom.xml =================================================================== --- hk2-runlevel/pom.xml (revision 4270) +++ hk2-runlevel/pom.xml (working copy) @@ -60,12 +60,7 @@ org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: hk2-utils/pom.xml =================================================================== --- hk2-utils/pom.xml (revision 4270) +++ hk2-utils/pom.xml (working copy) @@ -59,20 +59,16 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin + true - foo - ${project.build.outputDirectory}/META-INF/MANIFEST.MF @@ -132,6 +128,5 @@ true provided - Index: external/cglib/pom.xml =================================================================== --- external/cglib/pom.xml (revision 4270) +++ external/cglib/pom.xml (working copy) @@ -49,30 +49,39 @@ org.glassfish.hk2.external 4.0.0 cglib - - jar cglib version ${cglib.version} repackaged as a module + + + ss141213 + Sahoo + Sun Microsystems, Inc. + + developer + + + + org.apache.maven.plugins maven-clean-plugin + 2.4.1 - enforce-clean - + enforce-clean + process-sources clean - - - + + + org.apache.maven.plugins maven-dependency-plugin @@ -173,38 +182,27 @@ jar-no-fork - - - - org.apache.maven.plugins - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - + + + + org.apache.maven.plugins + maven-jar-plugin + + true + + + + - cglib - cglib - ${cglib.version} - true + cglib + cglib + ${cglib.version} + true - - - ss141213 - Sahoo - Sun Microsystems, Inc. - - developer - - - Index: hk2/pom.xml =================================================================== --- hk2/pom.xml (revision 4270) +++ hk2/pom.xml (working copy) @@ -56,7 +56,6 @@ org.apache.maven.plugins maven-source-plugin - 2.1 true @@ -73,17 +72,14 @@ maven-jar-plugin 2.4 - - - true - custom - $${artifact.artifactId}.$${artifact.extension} - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true + + + true + custom + $${artifact.artifactId}.$${artifact.extension} + + Index: hk2-api/pom.xml =================================================================== --- hk2-api/pom.xml (revision 4270) +++ hk2-api/pom.xml (working copy) @@ -59,21 +59,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - - foo - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: osgi/adapter/pom.xml =================================================================== --- osgi/adapter/pom.xml (revision 4270) +++ osgi/adapter/pom.xml (working copy) @@ -65,18 +65,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: osgi/adapter-tests/test-module-startup/pom.xml =================================================================== --- osgi/adapter-tests/test-module-startup/pom.xml (revision 4270) +++ osgi/adapter-tests/test-module-startup/pom.xml (working copy) @@ -58,18 +58,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: osgi/adapter-tests/contract-bundle/pom.xml =================================================================== --- osgi/adapter-tests/contract-bundle/pom.xml (revision 4270) +++ osgi/adapter-tests/contract-bundle/pom.xml (working copy) @@ -58,18 +58,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: osgi/adapter-tests/sdp-management-bundle/pom.xml =================================================================== --- osgi/adapter-tests/sdp-management-bundle/pom.xml (revision 4270) +++ osgi/adapter-tests/sdp-management-bundle/pom.xml (working copy) @@ -49,7 +49,6 @@ sdp-management-bundle - jar Manages the faux sdp management bundle ${project.name} @@ -58,18 +57,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: osgi/adapter-tests/faux-sdp-bundle/pom.xml =================================================================== --- osgi/adapter-tests/faux-sdp-bundle/pom.xml (revision 4270) +++ osgi/adapter-tests/faux-sdp-bundle/pom.xml (working copy) @@ -49,7 +49,6 @@ faux-sdp-bundle - jar Simulates a bundle ${project.name} @@ -58,18 +57,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true @@ -88,24 +81,17 @@ org.glassfish.hk2 hk2-inhabitant-generator - ${project.version} + ${project.version} - - true - - generateInhabitants + generate-inhabitants - test - process-test-classes - - true - + generate-test-inhabitants - generateInhabitants + generate-test-inhabitants Index: config-types/pom.xml =================================================================== --- config-types/pom.xml (revision 4270) +++ config-types/pom.xml (working copy) @@ -80,7 +80,7 @@ - generateInjectors + generate-injectors Index: examples/ctm/pom.xml =================================================================== --- examples/ctm/pom.xml (revision 4270) +++ examples/ctm/pom.xml (working copy) @@ -67,12 +67,7 @@ org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true @@ -95,46 +90,17 @@ - generateInjectors + generate-injectors test-generation - - true - - generate-test-sources - generateInjectors + generate-test-injectors - - org.glassfish.hk2 - hk2-inhabitant-generator - ${project.version} - - - - true - - - generateInhabitants - - - - test - process-test-classes - - true - - - generateInhabitants - - - - Index: examples/security-lockdown/mallory/pom.xml =================================================================== --- examples/security-lockdown/mallory/pom.xml (revision 4270) +++ examples/security-lockdown/mallory/pom.xml (working copy) @@ -58,18 +58,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: examples/security-lockdown/system/pom.xml =================================================================== --- examples/security-lockdown/system/pom.xml (revision 4270) +++ examples/security-lockdown/system/pom.xml (working copy) @@ -58,18 +58,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: examples/security-lockdown/runner/pom.xml =================================================================== --- examples/security-lockdown/runner/pom.xml (revision 4270) +++ examples/security-lockdown/runner/pom.xml (working copy) @@ -63,12 +63,7 @@ org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: examples/security-lockdown/alice/pom.xml =================================================================== --- examples/security-lockdown/alice/pom.xml (revision 4270) +++ examples/security-lockdown/alice/pom.xml (working copy) @@ -58,18 +58,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true Index: examples/custom-resolver/pom.xml =================================================================== --- examples/custom-resolver/pom.xml (revision 4270) +++ examples/custom-resolver/pom.xml (working copy) @@ -58,18 +58,12 @@ org.glassfish.hk2 osgiversion-maven-plugin - ${project.version} org.apache.maven.plugins maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + true