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

finding sources automatically by default - from the existing source sets #3

Merged
merged 2 commits into from
Mar 3, 2018

Conversation

ph4r05
Copy link
Contributor

@ph4r05 ph4r05 commented Feb 23, 2018

Hi!

similarly to #2 I find useful to auto-detect sources for the CAP compilation.

The thing is when the gradle project has somehow different project layout and the sourcesets are changed, e.g., as below, the project.sourceSets.main.java.srcDirs[0] still points to the original directory.

sourceSets {
    main {
        java {
            srcDir 'project/src/main/java'
        }
    }
}

My improvement adds few more switches so it iterates over source dirs (if findSources is enabled) and picks the first existing source directory.

This helped me a lot not to duplicate source dir settings as it successfully detects source set dir defined from the project.

Thanks for consideration!

@coveralls
Copy link

coveralls commented Feb 23, 2018

Coverage Status

Coverage decreased (-0.7%) to 88.727% when pulling 3abb456 on ph4r05:sourceset-detection into eb48a51 on bertrandmartel:master.

@bertrandmartel
Copy link
Owner

Hello, do you have a project layout example using this ?
The example you have shown would also work with sources such as :

cap {
    packageName 'fr.bmartel.aram'
    version '0.1'
    aid packageAid
    output 'applet.cap'
    sources 'project/src/main/java'
    applet {
        className 'fr.bmartel.aram.AccessRuleMaster'
        aid appletAid
    }
    dependencies {
        remote 'fr.bmartel:gplatform:2.1.1'
    }
}

But in IntelIJIdea or Android Studio, this directory will not be recognized as Java source but the plugin will consider the sources as project/src/main/java which will compile the right directory source

@ph4r05
Copy link
Contributor Author

ph4r05 commented Mar 1, 2018

@bertrandmartel Thanks for the review!

my aim is to prevent duplication of the source path, i.e., use the one defined in the sourceset for the gradle project. The original code still used the previous sourceset directory so I had to over specify the gradle, once in source sets for IntelliJ Idea and tests and also in the cap configuration. I would like to have both: use non-standard project layout for sources and to IntelliJ idea recognize those files as Java project files and to make cap out of it :)

Here is the example usage:
https://github.com/ph4r05-edu/javacard-calculator-wrapper/blob/master/applet/build.gradle

Typical motivation is to use gradle build for an existing project which has non-standard project layout. And I want all features like, IntelliJ idea project working correctly, tests, cap building.

Thanks for consideration

@bertrandmartel bertrandmartel merged commit d98deb0 into bertrandmartel:master Mar 3, 2018
@bertrandmartel
Copy link
Owner

@ph4r05 Thanks a lot, I agree it should take the 1st non empty source dir of sourceSets without specifying explicitly the path like sources 'project/src/main/java'

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.

3 participants