8000 Added support for getting a list of files from a jar directory in ResourceOf. by PeJetuz · Pull Request #1757 · yegor256/cactoos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added support for getting a list of files from a jar directory in ResourceOf. #1757

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PeJetuz
Copy link
@PeJetuz PeJetuz commented Jan 22, 2025

Added support for getting file names when reading a directory from a jar.
Added a test for getting file names when reading a directory.
Added 'test-data' module that builds a test jar file.

@PeJetuz
Copy link
Author
PeJetuz commented Jan 24, 2025

@yegor256 Will you please review?

@yegor256
Copy link
Owner

@PeJetuz thanks for the contribution! I'm not sure the location of the test-data/ directory is correct. I believe, all test resources and data must stay inside src/test/ directory, by convention in Maven.

@PeJetuz
Copy link
Author
PeJetuz commented Jan 27, 2025

@yegor256 Thanks! I don't like test-data/ either. I thought maybe someone would like the original project to build test-data-0.0.1.jar. Since it only contains 3 text files, it should be easy to recreate.

@yegor256
Copy link
Owner

@PeJetuz indeed, it's good to have sources in Git repo, instead of a binary .jar. But we should keep files in the src/test/, not in the root.

@PeJetuz
Copy link
Author
PeJetuz commented Jan 27, 2025

@yegor256 Now test-data-0.0.1.jar is in src/test/resources/. For testing, we need to have a separate jar file in the classpath. Then in tests we can get a list of files from this jar. Or I don't understand something, please explain.

@yegor256
Copy link
Owner

@PeJetuz "force push" is a bad idea in general, because it's confusing for the reviewer (just FYI)

@yegor256
Copy link
Owner

@PeJetuz it's not a good idea to keep binary files inside Git repository. Better generate/build this JAR in compile time, and place into target/. You can use maven-assembly-plugin for that and some test data from src/test/.

@PeJetuz
Copy link
Author
PeJetuz commented Jan 27, 2025

@yegor256 I thought it was important to you that the intermediate results were not included in the final commit. Thank you, I will fix it!

Added building test data in test-lib.jar before compilation.
@PeJetuz
Copy link
Author
PeJetuz commented Jan 28, 2025

@yegor256 Done. Thanks!

Collectors.joining("\n")
)
.getBytes(StandardCharsets.UTF_8)
);
Copy link
Owner
@yegor256 yegor256 Jan 28, 2025

Choose a reason for hiding this comment

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

@PeJetuz why not this formatting instead?

return new InputStreamOf(
  names
    .stream()
    .collect(Collectors.joining("\n"))
    .getBytes(StandardCharsets.UTF_8)
);

Copy link
Author

Choose a reason for hiding this comment

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

@yegor256 Done.

final String name = entry.getName();
if (this.path.equals(name)) {
continue;
} else if (name.lastIndexOf(this.path) >= 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Author
8000

Choose a reason for hiding this comment

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

@yegor256 Thanks for the article. I replaced while/if/else with stream.

@yegor256
Copy link
Owner

@PeJetuz looks much better now, but I still suggest placing it into src/test/ instead of src/test/resources/. All files from src/test/resources/ are automatically moved to target/test-classes/. I believe, this is not your plan for these files.

Replaced while and if/else to stream.
@PeJetuz
Copy link
Author
PeJetuz commented Jan 30, 2025

@yegor256 I changed the location of test-lib to src/test. I replaced while/if/else with stream and fixed the formatting.
Sorry, I didn't know force-push breaks changelog.
Thanks for your help!

@PeJetuz
Copy link
Author
PeJetuz commented Feb 6, 2025

@yegor256 Hi! Is there anything else that needs to be improved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0