Skip to content
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

Minor cleanups after merging WAR Gradle support contribution #1072

Merged
merged 5 commits into from
Oct 1, 2018

Conversation

chanseokoh
Copy link
Member

Minor cleanups after #923.

@Nullable private Path explodedWarDirectory;

public void setWarFile(Path warFile) {
from(getProject().zipTree(warFile.toFile()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can just be zipTree(warFile)

into(explodedWarDirectory);
}

@OutputDirectory
@Nullable
public File getExplodedWarDirectory() {
public Path getExplodedWarDirectory() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I recall from before that Path does not work with @OutputDirectory up-to-date checks. We should confirm that trying to run this task again skips the task correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, that's a good thing to know. Let me check, but I see we may need to revert it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, confirmed we should keep File for Gradle tasks.

@@ -185,7 +179,7 @@ private static JavaLayerConfigurations getForWarProject(

Path explodedWarPath = GradleProjectProperties.getExplodedWarDirectory(project);

Path libOutputDirectory = explodedWarPath.resolve(WEB_INF_LIB);
Path libOutputDirectory = explodedWarPath.resolve("WEB-INF/lib");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for removing the constants here?

Copy link
Member Author

@chanseokoh chanseokoh Oct 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are pros and cons, but I thought pros of removing constants have more benefits, particularly for readability.

  • WEB_INF_LIB will always be "WEB-INF/lib". If it's something we may change in the future (like some default value of our choice), I can see a good reason for having the constant declared in the top of the file, but in this case, it's always static.
  • Readability: I keep looking into the actual value of WEB_INB_LIB to see what libOutputDirectory actually is. With "WEB-INF/lib", it's directly recognizable.
  • Looking at the field WEB_INF_LIB makes me wonder at which places this constant is being referenced to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think? I'm actually fine with other ways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that sounds good 👍


} else if (Files.isDirectory(path)) {
try (Stream<Path> dirStream = Files.list(path)) {
if (!dirStream.findAny().isPresent()) {
try (Stream<Path> stream = Files.list(path)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: directoryStream/filesStream/files?

.walk(
path -> {
AbsoluteUnixPath pathInContainer =
classesExtractionPath.resolve(webInfClasses.relativize(path));

if (FileSystems.getDefault().getPathMatcher("glob:**.class").matches(path)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I believe this can be simplified to just like path.getFilename().toString().endsWith(".class")

This was referenced Oct 1, 2018
@chanseokoh chanseokoh merged commit f1c1bb4 into master Oct 1, 2018
@chanseokoh chanseokoh deleted the CryilleH-war-support-cleanups branch October 1, 2018 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants