-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only include bootstrap dependencies in quarkus:dev ClassPath #12156
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
import java.util.jar.Manifest; | ||
import java.util.stream.Collectors; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipFile; | ||
import java.util.zip.ZipOutputStream; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
|
@@ -75,6 +76,7 @@ | |
import org.eclipse.aether.util.artifact.JavaScopes; | ||
|
||
import io.quarkus.bootstrap.model.AppArtifactKey; | ||
import io.quarkus.bootstrap.model.AppModel; | ||
import io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions; | ||
import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; | ||
import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace; | ||
|
@@ -93,6 +95,7 @@ | |
*/ | ||
@Mojo(name = "dev", defaultPhase = LifecyclePhase.PREPARE_PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) | ||
public class DevMojo extends AbstractMojo { | ||
private static final String EXT_PROPERTIES_PATH = "META-INF/quarkus-extension.properties"; | ||
|
||
/** | ||
* running any one of these phases means the compile phase will have been run, if these have | ||
|
@@ -717,11 +720,35 @@ void prepare(final boolean triggerCompile) throws Exception { | |
|
||
//in most cases these are not used, however they need to be present for some | ||
//parent-first cases such as logging | ||
//first we go through and get all the parent first artifacts | ||
Set<AppArtifactKey> parentFirstArtifacts = new HashSet<>(); | ||
for (Artifact appDep : project.getArtifacts()) { | ||
if (appDep.getArtifactHandler().getExtension().equals("jar") && appDep.getFile().isFile()) { | ||
try (ZipFile file = new ZipFile(appDep.getFile())) { | ||
ZipEntry entry = file.getEntry(EXT_PROPERTIES_PATH); | ||
if (entry != null) { | ||
Properties p = new Properties(); | ||
try (InputStream inputStream = file.getInputStream(entry)) { | ||
p.load(inputStream); | ||
String parentFirst = p.getProperty(AppModel.PARENT_FIRST_ARTIFACTS); | ||
if (parentFirst != null) { | ||
String[] artifacts = parentFirst.split(","); | ||
for (String artifact : artifacts) { | ||
parentFirstArtifacts.add(new AppArtifactKey(artifact.split(":"))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is AppArtifactKey.fromString(str) actually. |
||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
for (Artifact appDep : project.getArtifacts()) { | ||
// only add the artifact if it's present in the dev mode context | ||
// we need this to avoid having jars on the classpath multiple times | ||
if (!devModeContext.getLocalArtifacts().contains(new AppArtifactKey(appDep.getGroupId(), appDep.getArtifactId(), | ||
appDep.getClassifier(), appDep.getArtifactHandler().getExtension()))) { | ||
AppArtifactKey key = new AppArtifactKey(appDep.getGroupId(), appDep.getArtifactId(), | ||
appDep.getClassifier(), appDep.getArtifactHandler().getExtension()); | ||
if (!devModeContext.getLocalArtifacts().contains(key) && parentFirstArtifacts.contains(key)) { | ||
addToClassPaths(classPathManifest, appDep.getFile()); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ protected static String[] split(String str, String[] parts, int fromIndex) { | |
protected final String classifier; | ||
protected final String type; | ||
|
||
protected AppArtifactKey(String[] parts) { | ||
public AppArtifactKey(String[] parts) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like this change is necessary. There is already There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes the code a lot simpler. This is the ctor that is used by the existing code that reads from quarkus-extensions.properties, I would need to copy the logic. |
||
this.groupId = parts[0]; | ||
this.artifactId = parts[1]; | ||
if (parts.length == 2 || parts[2] == null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's
io.quarkus.bootstrap.BootstrapConstants.DESCRIPTOR_PATH
, btw.