Skip to content

Commit

Permalink
Merge branch 'master' into pr-2202
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskleeh committed Oct 29, 2019
2 parents b4295b5 + 9d177ee commit 2635f4a
Show file tree
Hide file tree
Showing 568 changed files with 17,496 additions and 2,926 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ public void visitSuperBeanDefinitionFactory(String beanName) {
@Override
public void visitSetterValue(
Object declaringType,
Object returnType,
AnnotationMetadata annotationMetadata,
boolean requiresReflection,
Object fieldType,
Expand All @@ -1038,13 +1039,14 @@ public void visitSetterValue(
Map<String, Object> genericTypes,
boolean isOptional) {
deferredInjectionPoints.add(() -> proxyBeanDefinitionWriter.visitSetterValue(
declaringType, annotationMetadata, requiresReflection, fieldType, fieldName, setterName, genericTypes, isOptional
declaringType, returnType, annotationMetadata, requiresReflection, fieldType, fieldName, setterName, genericTypes, isOptional
));
}

@Override
public void visitSetterValue(
Object declaringType,
Object returnType,
AnnotationMetadata setterMetadata,
boolean requiresReflection,
Object valueType,
Expand All @@ -1055,6 +1057,7 @@ public void visitSetterValue(
deferredInjectionPoints.add(() ->
proxyBeanDefinitionWriter.visitSetterValue(
declaringType,
returnType,
setterMetadata,
requiresReflection,
valueType,
Expand Down
1 change: 0 additions & 1 deletion bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ publishing {
xml.children().last() + {
def mkp = delegate

mkp.packaging "pom"
mkp.properties {
for(dep in dependencyVersions) {
def v = dep.value.version
Expand Down
22 changes: 20 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,26 @@ ext {
version:micronautMicrometerVersion,
group:'io.micronaut.configuration',
name:'micronaut-micrometer-core',
modules:['micronaut-micrometer-registry-atlas', 'micronaut-micrometer-registry-graphite',
'micronaut-micrometer-registry-prometheus', 'micronaut-micrometer-registry-statsd' ]
modules:[
'micronaut-micrometer-registry-appoptics',
'micronaut-micrometer-registry-atlas',
'micronaut-micrometer-registry-azure-monitor',
'micronaut-micrometer-registry-cloudwatch',
'micronaut-micrometer-registry-datadog',
'micronaut-micrometer-registry-dynatrace',
'micronaut-micrometer-registry-elastic',
'micronaut-micrometer-registry-ganglia',
'micronaut-micrometer-registry-graphite',
'micronaut-micrometer-registry-humio',
'micronaut-micrometer-registry-influx',
'micronaut-micrometer-registry-jmx',
'micronaut-micrometer-registry-kairos',
'micronaut-micrometer-registry-new-relic',
'micronaut-micrometer-registry-prometheus',
'micronaut-micrometer-registry-signalfx',
'micronaut-micrometer-registry-stackdriver',
'micronaut-micrometer-registry-statsd',
'micronaut-micrometer-registry-wavefront']
],
'micronaut.spring': [
version:micronautSpringVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ class DependencyVersions implements DependencyManagement {
@CompileDynamic
void addDependencyManagement(GPathResult pom) {
pom.dependencyManagement.dependencies.dependency.each { dep ->
addDependency(dep.groupId.text(), dep.artifactId.text(), dep.version.text())
String version = dep.version.text()
if (version.startsWith('${')) {
String property = version[2..-2]
def child = pom.getProperty("properties").children().find {
it.name() == property
}
if (child) {
version = child.text()
}
}
addDependency(dep.groupId.text(), dep.artifactId.text(), version)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package io.micronaut.cli.io.support

import io.micronaut.cli.profile.Feature
import io.micronaut.cli.profile.Profile
import io.micronaut.cli.profile.ProfileRepository
import org.eclipse.aether.graph.Dependency
import org.eclipse.aether.graph.Exclusion
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector
Expand All @@ -30,7 +31,7 @@ abstract class BuildTokens {
this.appname = appname
}

abstract Map getTokens(Profile profile, List<Feature> features)
abstract Map getTokens(ProfileRepository profileRepository, Profile profile, List<Feature> features)

protected List<Dependency> materializeDependencies(Profile profile, List<Feature> features) {
List<Dependency> profileDependencies = profile.dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package io.micronaut.cli.io.support
import groovy.transform.InheritConstructors
import io.micronaut.cli.profile.Feature
import io.micronaut.cli.profile.Profile
import io.micronaut.cli.profile.ProfileRepository
import io.micronaut.cli.profile.repository.MavenProfileRepository
import io.micronaut.cli.util.VersionInfo
import org.eclipse.aether.graph.Dependency
Expand All @@ -29,7 +30,7 @@ import org.eclipse.aether.graph.Dependency
@InheritConstructors
class GradleBuildTokens extends BuildTokens {

Map getTokens(Profile profile, List<Feature> features) {
Map getTokens(ProfileRepository profileRepository, Profile profile, List<Feature> features) {
Map tokens = [:]
tokens.put("testFramework", testFramework)
tokens.put("sourceLanguage", sourceLanguage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import groovy.transform.InheritConstructors
import groovy.xml.MarkupBuilder
import io.micronaut.cli.profile.Feature
import io.micronaut.cli.profile.Profile
import io.micronaut.cli.profile.ProfileRepository
import io.micronaut.cli.profile.repository.MavenProfileRepository
import io.micronaut.cli.util.VersionInfo
import org.eclipse.aether.artifact.Artifact
import org.eclipse.aether.graph.Dependency
import org.eclipse.aether.graph.Exclusion

Expand All @@ -47,7 +49,7 @@ class MavenBuildTokens extends BuildTokens {
}

@Override
Map getTokens(Profile profile, List<Feature> features) {
Map getTokens(ProfileRepository profileRepository, Profile profile, List<Feature> features) {
Map tokens = [:]
tokens.put("testFramework", testFramework)
tokens.put("sourceLanguage", sourceLanguage)
Expand Down Expand Up @@ -143,14 +145,21 @@ class MavenBuildTokens extends BuildTokens {
annotationProcessorPathsXml."$methodToCall" {
groupId(artifact.groupId)
artifactId(artifact.artifactId)
def artifactVersion = artifact.version
if (!artifactVersion || artifactVersion == 'BOM') {
def resolvedVersion = profileRepository.findVersion(artifact.artifactId)
if (resolvedVersion ) {
artifactVersion = resolvedVersion
}
}
if (artifact.groupId.startsWith("io.micronaut")) {
if (!artifact.version || artifact.version == 'BOM') {
if (!artifactVersion || artifactVersion == 'BOM') {
version("\${micronaut.version}")
} else {
version(artifact.version)
version(artifactVersion)
}
} else {
version(artifact.version)
version(artifactVersion)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ package io.micronaut.cli.profile

import io.micronaut.cli.io.support.Resource
import org.eclipse.aether.artifact.Artifact
import org.eclipse.aether.graph.Dependency

import javax.annotation.Nullable

/**
*
Expand Down Expand Up @@ -70,4 +73,11 @@ interface ProfileRepository {
* @return The {@link Artifact} that resolves to the profile
*/
Artifact getProfileArtifact(String profileName)

/**
* Finds the version for the given artifact ID.
* @return the version
*/
@Nullable String findVersion(String artifactId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ abstract class AbstractCreateCommand extends ArgumentCompletingCommand implement
return
}

Map tokens = buildTokens.getTokens(profile, features)
Map tokens = buildTokens.getTokens(profileRepository, profile, features)

if (tokens == null) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.micronaut.cli.profile.ProjectContext
import io.micronaut.cli.profile.ProjectContextAware
import org.eclipse.aether.artifact.Artifact
import org.eclipse.aether.artifact.DefaultArtifact
import org.eclipse.aether.graph.Dependency

/**
* A repository that loads profiles from JAR files
Expand All @@ -48,6 +49,11 @@ abstract class AbstractJarProfileRepository implements ProfileRepository {
return profilesByName[profileName]
}

@Override
String findVersion(String artifactId) {
return null
}

@Override
Profile getProfile(String profileName, Boolean parentProfile) {
return getProfile(profileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class MavenProfileRepository extends AbstractJarProfileRepository {
this([DEFAULT_REPO])
}

@Override
@CompileDynamic
String findVersion(String artifactId) {
return profileDependencyVersions.find(artifactId)?.version
}

@Override
Profile getProfile(String profileName, Boolean parentProfile) {
String profileShortName = profileName
Expand Down
13 changes: 12 additions & 1 deletion cli/src/main/resources/unixStartScript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,19 @@ save () {
echo " "
}
APP_ARGS=\$(save "\$@")
JAVA_ADD_OPENS="\$(java --add-opens 2>&1)"
if [ -z "\${JAVA_ADD_OPENS##*Unrecognized*}" ] ; then
JAVA_MODULES_UNSUPPORTED=true
else
JAVA_OPTS="\$JAVA_OPTS -Dgroovy.jaxb=jaxb"
JAVA_OPTS="\$JAVA_OPTS --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.annotation=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.module=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.net.spi=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.channels=ALL-UNNAMED --add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.nio.charset.spi=ALL-UNNAMED --add-opens=java.base/java.nio.file=ALL-UNNAMED --add-opens=java.base/java.nio.file.attribute=ALL-UNNAMED --add-opens=java.base/java.nio.file.spi=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.security.acl=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.security.interfaces=ALL-UNNAMED --add-opens=java.base/java.security.spec=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.text.spi=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.time.chrono=ALL-UNNAMED --add-opens=java.base/java.time.format=ALL-UNNAMED --add-opens=java.base/java.time.temporal=ALL-UNNAMED --add-opens=java.base/java.time.zone=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/java.util.function=ALL-UNNAMED --add-opens=java.base/java.util.jar=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.util.spi=ALL-UNNAMED --add-opens=java.base/java.util.stream=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.datatransfer/java.awt.datatransfer=ALL-UNNAMED --add-opens=java.desktop/java.applet=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.color=ALL-UNNAMED --add-opens=java.desktop/java.awt.desktop=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/java.awt.geom=ALL-UNNAMED --add-opens=java.desktop/java.awt.im=ALL-UNNAMED --add-opens=java.desktop/java.awt.im.spi=ALL-UNNAMED --add-opens=java.desktop/java.awt.image=ALL-UNNAMED --add-opens=java.desktop/java.awt.image.renderable=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.print=ALL-UNNAMED --add-opens=java.desktop/java.beans=ALL-UNNAMED --add-opens=java.desktop/java.beans.beancontext=ALL-UNNAMED --add-opens=java.instrument/java.lang.instrument=ALL-UNNAMED --add-opens=java.logging/java.util.logging=ALL-UNNAMED --add-opens=java.management/java.lang.management=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.rmi/java.rmi=ALL-UNNAMED --add-opens=java.rmi/java.rmi.activation=ALL-UNNAMED --add-opens=java.rmi/java.rmi.dgc=ALL-UNNAMED --add-opens=java.rmi/java.rmi.registry=ALL-UNNAMED --add-opens=java.rmi/java.rmi.server=ALL-UNNAMED --add-opens=java.sql/java.sql=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.border=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.base/sun.nio.fs=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED"
# sun.awt.windows just on windows platforms
if [ \$msys = 'true' ] || [ \$cygwin = 'true' ]; then
JAVA_OPTS="\$JAVA_OPTS --add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED"
fi
fi

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" ${mainClassName} "\$APP_ARGS"

exec "\$JAVACMD" "\$@"
exec "\$JAVACMD" "\$@"
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,44 @@ public <E extends Enum> Optional<E> enumValue(@Nonnull String member, @Nonnull C
if (StringUtils.isNotEmpty(member)) {
Object o = getRawSingleValue(member, valueMapper);
if (o != null) {
if (enumType.isInstance(o)) {
return Optional.of((E) o);
} else {
try {
E e = (E) Enum.valueOf(enumType, o.toString());
return Optional.of(e);
} catch (IllegalArgumentException ex) {
return Optional.empty();
}
}
return convertToEnum(enumType, o);
}
}
return Optional.empty();
}

/**
* Return the enum values of the given member of the given enum type.
*
* @param member The annotation member
* @param enumType The required type
* @return An array of enum values
* @param <E> The enum type
*/
@Override
@SuppressWarnings("unchecked")
public <E extends Enum> E[] enumValues(@Nonnull String member, @Nonnull Class<E> enumType) {
ArgumentUtils.requireNonNull("enumType", enumType);
List<E> list = new ArrayList<>();
if (StringUtils.isNotEmpty(member)) {
Object rawValue = values.get(member);
if (rawValue != null) {
if (rawValue.getClass().isArray()) {
int len = Array.getLength(rawValue);
for (int i = 0; i < len; i++) {
convertToEnum(enumType, Array.get(rawValue, i)).ifPresent(list::add);
}
} else if (rawValue instanceof Iterable) {
for (Object o : (Iterable) rawValue) {
convertToEnum(enumType, o).ifPresent(list::add);
}
} else if (enumType.isAssignableFrom(rawValue.getClass())) {
list.add((E) rawValue);
}
}
}
return list.toArray((E[]) Array.newInstance(enumType, 0));
}

/**
* The value of the annotation as a Class.
Expand Down Expand Up @@ -958,4 +981,17 @@ private ConvertibleValues<Object> newConvertibleValues(Map<CharSequence, Object>
}
return rawValue;
}

private <T extends Enum> Optional<T> convertToEnum(Class<T> enumType, Object o) {
if (enumType.isInstance(o)) {
return Optional.of((T) o);
} else {
try {
T t = (T) Enum.valueOf(enumType, o.toString());
return Optional.of(t);
} catch (IllegalArgumentException ex) {
return Optional.empty();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ default <E extends Enum> Optional<E> enumValue(@Nonnull Class<E> enumType) {
return enumValue(AnnotationMetadata.VALUE_MEMBER, enumType);
}

/**
* Return the enum value of the given member of the given enum type.
*
* @param member The annotation member
* @param enumType The required type
* @return An {@link Optional} of the enum value
* @param <E> The enum type
*/
<E extends Enum> E[] enumValues(@Nonnull String member, @Nonnull Class<E> enumType);

/**
* Return the enum value of the given member of the given enum type.
*
* @param enumType The required type
* @return An {@link Optional} of the enum value
* @param <E> The enum type
*/
default <E extends Enum> E[] enumValues(@Nonnull Class<E> enumType) {
return enumValues(AnnotationMetadata.VALUE_MEMBER, enumType);
}

/**
* The value of the annotation as a Class.
*
Expand Down
Loading

0 comments on commit 2635f4a

Please sign in to comment.