Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions devtools/gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
compile "io.quarkus:quarkus-bootstrap-core:${version}"
compile "io.quarkus:quarkus-devtools-common:${version}"
compile "io.quarkus:quarkus-platform-descriptor-json:${version}"
compile "io.quarkus:quarkus-platform-descriptor-resolver-json:${version}"
compile "io.quarkus:quarkus-development-mode:${version}"
compile "io.quarkus:quarkus-creator:${version}"
compile "org.gradle:gradle-tooling-api:5.5.1"
Expand Down
5 changes: 5 additions & 0 deletions devtools/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-platform-descriptor-json</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-platform-descriptor-resolver-json</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.gradle.api.GradleException;
import org.gradle.api.Project;
Expand Down Expand Up @@ -48,6 +49,11 @@ public String getLatestVersion(AppArtifact arg0, String arg1, boolean arg2) thro
throw new UnsupportedOperationException();
}

@Override
public String getLatestVersionFromRange(AppArtifact appArtifact, String range) throws AppModelResolverException {
throw new UnsupportedOperationException();
}

@Override
public String getNextVersion(AppArtifact arg0, String fromVersion, boolean fromVersionIncluded, String arg1, boolean arg2)
throws AppModelResolverException {
Expand All @@ -67,7 +73,31 @@ public void relink(AppArtifact arg0, Path arg1) throws AppModelResolverException
@Override
public Path resolve(AppArtifact appArtifact) throws AppModelResolverException {
if (!appArtifact.isResolved()) {
throw new AppModelResolverException("Artifact has not been resolved: " + appArtifact);

final GradleDependencyArtifact dep = new GradleDependencyArtifact();
dep.setExtension(appArtifact.getType());
dep.setType(appArtifact.getType());
dep.setName(appArtifact.getArtifactId());

final QuarkusExtDependency gradleDep = new QuarkusExtDependency(appArtifact.getGroupId(),
appArtifact.getArtifactId(), appArtifact.getVersion(), null);
gradleDep.addArtifact(dep);

final Configuration detachedConfig = project.getConfigurations().detachedConfiguration(gradleDep);

final ResolvedConfiguration rc = detachedConfig.getResolvedConfiguration();
Set<ResolvedArtifact> resolvedArtifacts = rc.getResolvedArtifacts();
for (ResolvedArtifact a : resolvedArtifacts) {
if (appArtifact.getArtifactId().equals(a.getName())
&& appArtifact.getType().equals(a.getType())
&& appArtifact.getGroupId().equals(a.getModuleVersion().getId().getGroup())) {
appArtifact.setPath(a.getFile().toPath());
}
}

if (!appArtifact.isResolved()) {
throw new AppModelResolverException("Failed to resolve " + appArtifact);
}
}
return appArtifact.getPath();
}
Expand Down Expand Up @@ -125,17 +155,6 @@ public AppModel resolveModel(AppArtifact appArtifact) throws AppModelResolverExc
}
}

/*
* System.out.println("USER APP DEPENDENCIES");
* for (AppDependency dep : userDeps) {
* System.out.println(" " + dep);
* }
* System.out.println("DEPLOYMENT DEPENDENCIES");
* for (AppDependency dep : deploymentDeps) {
* System.out.println(" " + dep);
* }
*/

// In the case of quarkusBuild (which is the primary user of this),
// it's not necessary to actually resolve the original application JAR
if (!appArtifact.isResolved()) {
Expand Down Expand Up @@ -203,4 +222,4 @@ private Properties resolveDescriptor(final Path path) {
}
return rtProps;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package io.quarkus.gradle;

import org.gradle.api.artifacts.DependencyArtifact;

public class GradleDependencyArtifact implements DependencyArtifact {

private String classifier;
private String extension;
private String name;
private String type;
private String url;

@Override
public String getClassifier() {
return classifier;
}

@Override
public String getExtension() {
return extension;
}

@Override
public String getName() {
return name;
}

@Override
public String getType() {
return type;
}

@Override
public String getUrl() {
return url;
}

@Override
public void setClassifier(String arg0) {
this.classifier = arg0;
}

@Override
public void setExtension(String arg0) {
this.extension = arg0;
}

@Override
public void setName(String arg0) {
this.name = arg0;
}

@Override
public void setType(String arg0) {
this.type = arg0;
}

@Override
public void setUrl(String arg0) {
this.url = arg0;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((classifier == null) ? 0 : classifier.hashCode());
result = prime * result + ((extension == null) ? 0 : extension.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((url == null) ? 0 : url.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
GradleDependencyArtifact other = (GradleDependencyArtifact) obj;
if (classifier == null) {
if (other.classifier != null)
return false;
} else if (!classifier.equals(other.classifier))
return false;
if (extension == null) {
if (other.extension != null)
return false;
} else if (!extension.equals(other.extension))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
if (url == null) {
if (other.url != null)
return false;
} else if (!url.equals(other.url))
return false;
return true;
}

@Override
public String toString() {
return "GradleDepArtifact [classifier=" + classifier + ", extension=" + extension + ", name=" + name + ", type=" + type
+ ", url=" + url + "]";
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.quarkus.gradle;

import java.util.Set;

import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.DependencyArtifact;
import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.internal.artifacts.DefaultModuleIdentifier;
import org.gradle.api.internal.artifacts.dependencies.AbstractExternalModuleDependency;
Expand All @@ -20,13 +23,24 @@ public QuarkusExtDependency(String group, String name, String version, String co
this.configuration = configuration;
}

@Override
public Set<DependencyArtifact> getArtifacts() {
return super.getArtifacts();
}

@Override
public ExternalModuleDependency copy() {
return new QuarkusExtDependency(group, name, version, configuration);
QuarkusExtDependency copy = new QuarkusExtDependency(group, name, version, configuration);
final Set<DependencyArtifact> artifacts = getArtifacts();
for (DependencyArtifact a : artifacts) {
copy.addArtifact(a);
}
return copy;
}

@Override
public boolean contentEquals(Dependency arg0) {
new Exception("contentEquals " + arg0).printStackTrace();
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.quarkus.gradle.tasks;

import org.gradle.api.logging.Logger;

import io.quarkus.platform.tools.MessageWriter;

public class GradleMessageWriter implements MessageWriter {

private final Logger logger;

public GradleMessageWriter(Logger logger) {
this.logger = logger;
}

@Override
public void debug(String arg0) {
logger.debug(arg0);
}

@Override
public void error(String arg0) {
logger.error(arg0);
}

@Override
public void info(String arg0) {
logger.info(arg0);
}

@Override
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}

@Override
public void warn(String arg0) {
logger.warn(arg0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @author <a href="mailto:[email protected]">Ståle Pedersen</a>
*/
public class QuarkusAddExtension extends QuarkusTask {
public class QuarkusAddExtension extends QuarkusPlatformTask {

public QuarkusAddExtension() {
super("Adds Quarkus extensions specified by the user to the project.");
Expand All @@ -37,6 +37,9 @@ public List<String> getExtensionsToAdd() {

@TaskAction
public void addExtension() {

setupPlatformDescriptor();

Set<String> extensionsSet = new HashSet<>(getExtensionsToAdd());
try {
new AddExtensions(new GradleBuildFile(new FileProjectWriter(getProject().getProjectDir())))
Expand All @@ -45,5 +48,4 @@ public void addExtension() {
throw new GradleException("Failed to add extensions " + getExtensionsToAdd(), e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.gradle.tasks;

import java.io.File;
import java.io.IOException;

import org.gradle.api.GradleException;
Expand All @@ -16,13 +15,13 @@
/**
* @author <a href="mailto:[email protected]">Ståle Pedersen</a>
*/
public class QuarkusListExtensions extends QuarkusTask {
public class QuarkusListExtensions extends QuarkusPlatformTask {

private boolean all = true;

private String format = "concise";

private String searchPattern = null;
private String searchPattern;

@Optional
@Input
Expand Down Expand Up @@ -63,13 +62,16 @@ public QuarkusListExtensions() {

@TaskAction
public void listExtensions() {

setupPlatformDescriptor();

try {
new ListExtensions(new GradleBuildFileFromConnector(new FileProjectWriter(new File(getPath())))).listExtensions(
isAll(),
getFormat(), getSearchPattern());
new ListExtensions(new GradleBuildFileFromConnector(new FileProjectWriter(getProject().getProjectDir())))
.listExtensions(
isAll(),
getFormat(), getSearchPattern());
} catch (IOException e) {
throw new GradleException("Unable to list extensions", e);
}
}

}
Loading