Skip to content

Commit

Permalink
Merge branch '1.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Oct 14, 2019
2 parents 673cb46 + 272d5a8 commit 4beec0b
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 37 deletions.
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
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ developers=Graeme Rocher
micronautSpringVersion=1.0.1
micronautGcpVersion=1.1.0
micronautGrpcVersion=1.0.1
micronautAwsVersion=1.3.2
micronautAwsVersion=1.3.3
micronautRedisVersion=1.1.1
micronautMongoVersion=1.1.0
micronautNeo4jVersion=1.1.0
Expand Down
31 changes: 15 additions & 16 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,20 @@ publishing {
repositories {
maven {
credentials {
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
def bintrayUser = System.getenv("BINTRAY_USER") ?: project.hasProperty("bintrayUser") ? project.bintrayUser : ''
def bintrayKey = System.getenv("BINTRAY_KEY") ?: project.hasProperty("bintrayKey") ? project.bintrayKey : ''

username = ossUser
password = ossPass
}
if(isBuildSnapshot) {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
else {
url "https://repo.micronaut.io/artifactory/libs-releases-local"
username = bintrayUser
password = bintrayKey
}
url "https://oss.jfrog.org/oss-snapshot-local"
}
}

publications {
maven(MavenPublication) { publication ->
artifactId( "micronaut-" + project.name.substring(project.name.indexOf('/') + 1) )

def shadowJar = tasks.findByName("shadowJar")
if(shadowJar && shadowJar.enabled) {
artifact(project.tasks.shadowJar) {
Expand Down Expand Up @@ -151,12 +147,15 @@ publishing {

}
else {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"

if (project.name != 'bom') {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
}

pom.withXml {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.micronaut.core.annotation.AnnotationClassValue;
import io.micronaut.core.annotation.AnnotationUtil;
import io.micronaut.core.util.ArrayUtils;
import io.micronaut.core.util.StringUtils;
import io.micronaut.core.value.OptionalValues;
import io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder;
Expand Down Expand Up @@ -557,6 +558,13 @@ private class ArrayValueVisitor extends AbstractAnnotationValueVisitor8<Object,

Object[] getValues() {
if (arrayType != null) {
for (Object value : values) {
if (value != null) {
if (!arrayType.isInstance(value)) {
return ArrayUtils.EMPTY_OBJECT_ARRAY;
}
}
}
return values.toArray((Object[]) Array.newInstance(arrayType, values.size()));
} else {
return values.toArray(new Object[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected AbstractBeanConfiguration(String thePackage) {

@Override
public Package getPackage() {
return Package.getPackage(packageName);
return getClass().getPackage();
}

@Override
Expand Down
16 changes: 7 additions & 9 deletions src/main/docs/guide/appendix/usingsnapshots.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ ext {
micronautVersion = '1.0.2.BUILD-SNAPSHOT'
}
repositories {
mavenLocal()
mavenCentral()
jcenter() <1>
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } // <2>
maven { url "https://oss.jfrog.org/oss-snapshot-local" } // <2>
}
dependencyManagement {
imports {
Expand All @@ -20,8 +18,8 @@ dependencyManagement {
}
----

<1> Micronaut releases are available on jcenter
<2> Micronaut snapshots are available on sonatype
<1> Micronaut releases are available on JCenter and Maven Central
<2> Micronaut snapshots are available on JFrog OSS

In the case of Maven, edit `pom.xml`:

Expand All @@ -41,8 +39,8 @@ In the case of Maven, edit `pom.xml`:
<url>https://jcenter.bintray.com</url> <!--2-->
</repository>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url> <!--3-->
<id>jfrog-snapshots</id>
<url>https://oss.jfrog.org/oss-snapshot-local</url> <!--3-->
</repository>
</repositories>
Expand All @@ -63,5 +61,5 @@ In the case of Maven, edit `pom.xml`:
----
<1> Set the snapshot version.
<2> Micronaut releases are available on jcenter
<3> Micronaut snapshots are available on sonatype
<2> Micronaut releases are available on JCenter and Maven Central
<3> Micronaut snapshots are available on JFrog OSS Snapshots
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The above example will inject a client that targets the Twitter API.

[source,kotlin]
----
@Client("\${myapp.api.twitter.url}") @Inject httpClient: RxHttpClient
@field:Client("\${myapp.api.twitter.url}") @Inject lateinit var httpClient: RxHttpClient
----

The above Kotlin example will inject a client that targets the Twitter API using a configuration path. Note the required escaping (backslash) on `"\${path.to.config}"` which is required due to Kotlin string interpolation.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.micronaut.tracing.jaeger

import io.jaegertracing.Configuration
import io.micronaut.context.ApplicationContext
import spock.lang.Specification

class JaegerConfigurationSpec extends Specification {

void "test reporter configuration"() {
given:
def ctx = ApplicationContext.run(
'tracing.jaeger.enabled':'true',
'tracing.jaeger.sender.agentHost':'foo',
'tracing.jaeger.sender.agentPort':9999
)
def config = ctx.getBean(JaegerConfiguration).configuration

expect:
config.reporter.senderConfiguration.agentHost == 'foo'
config.reporter.senderConfiguration.agentPort == 9999
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ public void setSenderConfiguration(@Nullable Configuration.SenderConfiguration s
configuration.withSender(senderConfiguration);
}
}

/**
* Sets the sender configuration.
*
* @param senderConfiguration The sender configuration
*/
@Inject
public void setSenderConfiguration(@Nullable JaegerSenderConfiguration senderConfiguration) {
if (senderConfiguration != null) {
configuration.withSender(senderConfiguration.configuration);
}
}
}

/**
Expand Down

0 comments on commit 4beec0b

Please sign in to comment.