diff --git a/src/it/projects/MJAVADOC-769/invoker.properties b/src/it/projects/MJAVADOC-769/invoker.properties new file mode 100644 index 00000000..acf2b371 --- /dev/null +++ b/src/it/projects/MJAVADOC-769/invoker.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals= clean package +invoker.java.version = 9+ diff --git a/src/it/projects/MJAVADOC-769/pom.xml b/src/it/projects/MJAVADOC-769/pom.xml new file mode 100644 index 00000000..2f4853e2 --- /dev/null +++ b/src/it/projects/MJAVADOC-769/pom.xml @@ -0,0 +1,170 @@ + + + + 4.0.0 + + org.apache.maven.plugins.javadoc.it + mjavadoc769 + 1.0-SNAPSHOT + jar + + https://issues.apache.org/jira/browse/MJAVADOC-769 + + + UTF-8 + 9 + 9 + mavenbugs.mjavadoc769 + + + + + + org.junit + junit-bom + 5.10.0 + pom + import + + + + + + + com.google.inject + guice + 5.1.0 + + + + com.google.guava + guava + 31.1-jre + + + + jakarta.inject + jakarta.inject-api + 2.0.1.MR + provided + true + + + + javax.inject + javax.inject + 1 + provided + true + + + + org.junit.jupiter + junit-jupiter-api + test + + + + org.junit.jupiter + junit-jupiter-params + test + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + @project.version@ + + ${project.build.directory}/apidocs + + 11 + false + false + true + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + default-jar + + + + + + ${moduleName} + + + + + + + test-jar + + + + + + ${moduleName}.tests + + + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + javadoc-jar + package + + jar + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + test-jar + package + + test-jar + + + + + + + diff --git a/src/it/projects/MJAVADOC-769/src/main/java/mavenbugs/mjavadoc769/InternalImportBindingBuilder.java b/src/it/projects/MJAVADOC-769/src/main/java/mavenbugs/mjavadoc769/InternalImportBindingBuilder.java new file mode 100644 index 00000000..a2f6164b --- /dev/null +++ b/src/it/projects/MJAVADOC-769/src/main/java/mavenbugs/mjavadoc769/InternalImportBindingBuilder.java @@ -0,0 +1,116 @@ +package mavenbugs.mjavadoc769; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.lang.annotation.Annotation; + +import com.google.inject.Inject; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.Provider; +import com.google.inject.Scope; +import com.google.inject.TypeLiteral; +import com.google.inject.binder.LinkedBindingBuilder; +import com.google.inject.binder.ScopedBindingBuilder; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +/** + * Import binding builder. + */ +public final class InternalImportBindingBuilder implements ScopedBindingBuilder { + + private final Key concreteType; + private final ScopedBindingBuilder binder; + private final InternalBindingProvider provider; + + public InternalImportBindingBuilder(LinkedBindingBuilder binder, Key concreteType) { + checkNotNull(binder, "binder is null"); + + this.concreteType = checkNotNull(concreteType, "concreteType is null"); + + this.provider = new InternalBindingProvider<>(concreteType); + this.binder = binder.toProvider(provider); + } + + /** + * Bind a different type as the given binding. This allows binding e.g. implementations to interface types. + */ + public ScopedBindingBuilder to(Class clazz) { + checkNotNull(clazz, "clazz is null"); + + this.provider.setKey(concreteType.ofType(clazz)); + + return this; + } + + /** + * Bind a different type as the given binding. This allows binding e.g. implementations to interface types. + */ + public ScopedBindingBuilder to(TypeLiteral type) { + checkNotNull(type, "type is null"); + + this.provider.setKey(concreteType.ofType(type)); + + return this; + } + + @Override + public void in(Class scopeAnnotation) { + checkNotNull(scopeAnnotation, "scopeAnnotation is null"); + this.binder.in(scopeAnnotation); + } + + @Override + public void in(Scope scope) { + checkNotNull(scope, "scope is null"); + this.binder.in(scope); + } + + @Override + public void asEagerSingleton() { + this.binder.asEagerSingleton(); + } + + static final class InternalBindingProvider implements Provider { + + private Key key; + private Injector injector; + + InternalBindingProvider(Key key) { + this.key = checkNotNull(key, "key is null"); + } + + InternalBindingProvider setKey(Key key) { + this.key = checkNotNull(key, "key is null"); + return this; + } + + @Inject + void setInjector(final Injector injector) { + checkNotNull(injector, "injector is null"); + checkState(this.injector == null, "setInjector() called multiple times!"); + + this.injector = injector; + } + + @Override + public T get() { + checkState(this.injector != null, "calling get() before setInjector()!"); + return injector.getInstance(key); + } + } +} diff --git a/src/it/projects/MJAVADOC-769/src/test/java/mavenbugs/mjavadoc769/Right.java b/src/it/projects/MJAVADOC-769/src/test/java/mavenbugs/mjavadoc769/Right.java new file mode 100644 index 00000000..e9071e78 --- /dev/null +++ b/src/it/projects/MJAVADOC-769/src/test/java/mavenbugs/mjavadoc769/Right.java @@ -0,0 +1,28 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package mavenbugs.mjavadoc769; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@Target({FIELD, PARAMETER, METHOD}) +@javax.inject.Qualifier +@jakarta.inject.Qualifier +public @interface Right {} diff --git a/src/it/projects/MJAVADOC-769/src/test/java/mavenbugs/mjavadoc769/RightTest.java b/src/it/projects/MJAVADOC-769/src/test/java/mavenbugs/mjavadoc769/RightTest.java new file mode 100644 index 00000000..9888f962 --- /dev/null +++ b/src/it/projects/MJAVADOC-769/src/test/java/mavenbugs/mjavadoc769/RightTest.java @@ -0,0 +1,48 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package mavenbugs.mjavadoc769; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; + +import org.junit.jupiter.api.Test; + +public class RightTest { + + @Test + public void testFoo() throws Exception { + Method method = Foo.class.getMethod("foo"); + Annotation annotation = method.getAnnotation(Right.class); + assertNotNull(annotation); + } + + @Test + public void testRight() throws Exception { + Annotation[] annotations = Right.class.getAnnotations(); + assertEquals(4, annotations.length); + + assertEquals(javax.inject.Qualifier.class, Right.class.getAnnotation(javax.inject.Qualifier.class).annotationType()); + assertEquals(jakarta.inject.Qualifier.class, Right.class.getAnnotation(jakarta.inject.Qualifier.class).annotationType()); + } + + + public static class Foo { + @Right + public void foo() { + } + } +} diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index 5ff756b7..b0d401c7 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -4571,8 +4571,7 @@ private void addJavadocOptions( ModuleNameSource depModuleNameSource = locationManager .resolvePath(ResolvePathRequest.ofFile(file)) .getModuleNameSource(); - if (ModuleNameSource.MODULEDESCRIPTOR.equals(depModuleNameSource) - || ModuleNameSource.MANIFEST.equals(depModuleNameSource)) { + if (ModuleNameSource.MODULEDESCRIPTOR.equals(depModuleNameSource)) { modulePathElements.add(file); } else { patchModules.get(mainModuleName).add(file.toPath());