Excluding files and folders during plugin publishing
I want to exclude .svn
folders when I publish my plugin to our custom Artifactory repository. I'm assuming the inclusion of .svn
folders is the issue based on the error strack trace provided below.
I'm publishing using the following command:
gradlew artifactoryPublish --stacktrace
This is the publishing block in build.gradle
:
artifactory {
contextUrl = artifactory_context
publish {
repository {
repoKey = 'plugins-release-local'
username = artifactory_user
password = artifactory_password
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
This is the stack trace I get when I attempt to publish, notice the attempt copy of .svn/entries
to assets/entries
.
...
:copyAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':copyAssets'.
> Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':copyAssets'.
...
Caused by: org.gradle.api.GradleException: Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
...
Caused by: java.io.FileNotFoundException: /u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries (Permission denied)
... 80 more
The permission on entries
(both trees) are -r--r--r--
.
If I exclude those folders, I should get rid of said permission issue. The first checkout will always publish, but subsequent publishes (say after an update), fail with this error.
Update #2
Here are the three combination I tried without success:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
//first attempt
//exclude("**/.svn/**")
//second attempt
//exclude{ details -> details.file.name.contains(".svn") }
//third attempt
//exclude "**/.svn/**"
}
}
}
The error output when publishing, using all three attempts, is the following:
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method exclude() for arguments [build_3nsvrqvwahy23ir3fxdj970id$_run_closure7_closure13_closure14_closure15@10e9a5fe] on org.gradlpublish.maven.internal.publication.DefaultMavenPublication_Decorated@ca7e37f.
Update #3
I found the following link taking about excluding files.
I then adjusted my gradle.build
to this:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java {
exclude "**/.svn/**"
}
}
}
}
Same error.
Update #4
More attempts... same results
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar{
exclude '**/.svn/**'
}
}
}
}
or
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact exclude '**/.svn/**'
}
}
}
gradle build.gradle gradlew
add a comment |
I want to exclude .svn
folders when I publish my plugin to our custom Artifactory repository. I'm assuming the inclusion of .svn
folders is the issue based on the error strack trace provided below.
I'm publishing using the following command:
gradlew artifactoryPublish --stacktrace
This is the publishing block in build.gradle
:
artifactory {
contextUrl = artifactory_context
publish {
repository {
repoKey = 'plugins-release-local'
username = artifactory_user
password = artifactory_password
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
This is the stack trace I get when I attempt to publish, notice the attempt copy of .svn/entries
to assets/entries
.
...
:copyAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':copyAssets'.
> Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':copyAssets'.
...
Caused by: org.gradle.api.GradleException: Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
...
Caused by: java.io.FileNotFoundException: /u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries (Permission denied)
... 80 more
The permission on entries
(both trees) are -r--r--r--
.
If I exclude those folders, I should get rid of said permission issue. The first checkout will always publish, but subsequent publishes (say after an update), fail with this error.
Update #2
Here are the three combination I tried without success:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
//first attempt
//exclude("**/.svn/**")
//second attempt
//exclude{ details -> details.file.name.contains(".svn") }
//third attempt
//exclude "**/.svn/**"
}
}
}
The error output when publishing, using all three attempts, is the following:
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method exclude() for arguments [build_3nsvrqvwahy23ir3fxdj970id$_run_closure7_closure13_closure14_closure15@10e9a5fe] on org.gradlpublish.maven.internal.publication.DefaultMavenPublication_Decorated@ca7e37f.
Update #3
I found the following link taking about excluding files.
I then adjusted my gradle.build
to this:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java {
exclude "**/.svn/**"
}
}
}
}
Same error.
Update #4
More attempts... same results
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar{
exclude '**/.svn/**'
}
}
}
}
or
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact exclude '**/.svn/**'
}
}
}
gradle build.gradle gradlew
add a comment |
I want to exclude .svn
folders when I publish my plugin to our custom Artifactory repository. I'm assuming the inclusion of .svn
folders is the issue based on the error strack trace provided below.
I'm publishing using the following command:
gradlew artifactoryPublish --stacktrace
This is the publishing block in build.gradle
:
artifactory {
contextUrl = artifactory_context
publish {
repository {
repoKey = 'plugins-release-local'
username = artifactory_user
password = artifactory_password
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
This is the stack trace I get when I attempt to publish, notice the attempt copy of .svn/entries
to assets/entries
.
...
:copyAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':copyAssets'.
> Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':copyAssets'.
...
Caused by: org.gradle.api.GradleException: Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
...
Caused by: java.io.FileNotFoundException: /u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries (Permission denied)
... 80 more
The permission on entries
(both trees) are -r--r--r--
.
If I exclude those folders, I should get rid of said permission issue. The first checkout will always publish, but subsequent publishes (say after an update), fail with this error.
Update #2
Here are the three combination I tried without success:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
//first attempt
//exclude("**/.svn/**")
//second attempt
//exclude{ details -> details.file.name.contains(".svn") }
//third attempt
//exclude "**/.svn/**"
}
}
}
The error output when publishing, using all three attempts, is the following:
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method exclude() for arguments [build_3nsvrqvwahy23ir3fxdj970id$_run_closure7_closure13_closure14_closure15@10e9a5fe] on org.gradlpublish.maven.internal.publication.DefaultMavenPublication_Decorated@ca7e37f.
Update #3
I found the following link taking about excluding files.
I then adjusted my gradle.build
to this:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java {
exclude "**/.svn/**"
}
}
}
}
Same error.
Update #4
More attempts... same results
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar{
exclude '**/.svn/**'
}
}
}
}
or
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact exclude '**/.svn/**'
}
}
}
gradle build.gradle gradlew
I want to exclude .svn
folders when I publish my plugin to our custom Artifactory repository. I'm assuming the inclusion of .svn
folders is the issue based on the error strack trace provided below.
I'm publishing using the following command:
gradlew artifactoryPublish --stacktrace
This is the publishing block in build.gradle
:
artifactory {
contextUrl = artifactory_context
publish {
repository {
repoKey = 'plugins-release-local'
username = artifactory_user
password = artifactory_password
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
This is the stack trace I get when I attempt to publish, notice the attempt copy of .svn/entries
to assets/entries
.
...
:copyAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':copyAssets'.
> Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':copyAssets'.
...
Caused by: org.gradle.api.GradleException: Could not copy file '/u01/var/build/pluginXYZ/grails-app/assets/.svn/entries' to '/u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries'.
...
Caused by: java.io.FileNotFoundException: /u01/var/build/pluginXYZ/build/resources/main/META-INF/assets/entries (Permission denied)
... 80 more
The permission on entries
(both trees) are -r--r--r--
.
If I exclude those folders, I should get rid of said permission issue. The first checkout will always publish, but subsequent publishes (say after an update), fail with this error.
Update #2
Here are the three combination I tried without success:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
//first attempt
//exclude("**/.svn/**")
//second attempt
//exclude{ details -> details.file.name.contains(".svn") }
//third attempt
//exclude "**/.svn/**"
}
}
}
The error output when publishing, using all three attempts, is the following:
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method exclude() for arguments [build_3nsvrqvwahy23ir3fxdj970id$_run_closure7_closure13_closure14_closure15@10e9a5fe] on org.gradlpublish.maven.internal.publication.DefaultMavenPublication_Decorated@ca7e37f.
Update #3
I found the following link taking about excluding files.
I then adjusted my gradle.build
to this:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java {
exclude "**/.svn/**"
}
}
}
}
Same error.
Update #4
More attempts... same results
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar{
exclude '**/.svn/**'
}
}
}
}
or
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact exclude '**/.svn/**'
}
}
}
gradle build.gradle gradlew
gradle build.gradle gradlew
edited May 26 '16 at 20:06
TekiusFanatikus
asked May 11 '16 at 19:09
TekiusFanatikusTekiusFanatikus
1,39752762
1,39752762
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
Say, you have a file which you want to avoid ONLY while publishing to the repository. If you go with as suggested by @TekiusFanatikus
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
you will be able to achieve it but this will also exclude the file/folder etc. from the artifact that you generate using gradle build.
Instead, I would recommend to use the approach as mentioned here gradle documnetation
You can create a task which have your desired exclusion applied
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
and then refer the task while publishing.
publishing {
publications {
api(MavenPublication) {
groupId 'org.gradle.sample'
artifactId 'project2-api'
version '2'
artifact apiJar
}
}
}
This way, the jar that gets published will not have .svn folder. The point that I wanted to make here is that it will not touch your artifact that gets created using gradle build. It will still have your .svn folder.
But if you want it to be removed from both the places, then the best option is as suggested above.
add a comment |
I think you can use 'exclude' method with filefilter. Just add it under 'from' in publications block.
I've tried 3 different configuration (See update 2) without success. Not sure if I implemented what you had in mind.
– TekiusFanatikus
May 12 '16 at 12:21
It looks like your components.java is wrong try specifying the artifact explicitly like artifact file("path-to-jar/jar.jar").
– user3450486
May 12 '16 at 15:54
Not by any chance you could pseudo code something for me? So far, any attempts to append artifact with exclude, brings up the same error.
– TekiusFanatikus
May 16 '16 at 15:08
add a comment |
I would like to extend on @Neeraj answer. The problem with the custom JAR approach is with multi-module projects, in which the POM would not contain inner-project dependencies and will also be missing out external dependencies (they will be only part of the dependency-management section). This is in contrast to using the from components.java
approach in which the POM would turn out to be fine.
In order to overcome this, there is a need to manually edit the POM file. This is a pretty dirty solution, but the only one I could find:
project.afterEvaluate {
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
publishing {
publications {
api(MavenPublication) {
artifact apiJar
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
project.configurations.runtime.allDependencies.forEach { d ->
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", d.group)
dependencyNode.appendNode("artifactId", d.name)
dependencyNode.appendNode("version", d.version)
}
}
}
}
}
artifactoryPublish {
publications('api')
}
}
Update:
For anyone using the dependency-management plugin io.spring.dependency-management
, here's a way of correctly injecting the versions of all the dependencies into the POM:
def version = {
if (d.version != null) d.version
else dependencyManagement.managedVersions["${d.group}:${d.name}"]
}
dependencyNode.appendNode("version", version())
add a comment |
I appended the following at the root level in my build.gradle
and it seems to work:
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37171372%2fexcluding-files-and-folders-during-plugin-publishing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Say, you have a file which you want to avoid ONLY while publishing to the repository. If you go with as suggested by @TekiusFanatikus
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
you will be able to achieve it but this will also exclude the file/folder etc. from the artifact that you generate using gradle build.
Instead, I would recommend to use the approach as mentioned here gradle documnetation
You can create a task which have your desired exclusion applied
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
and then refer the task while publishing.
publishing {
publications {
api(MavenPublication) {
groupId 'org.gradle.sample'
artifactId 'project2-api'
version '2'
artifact apiJar
}
}
}
This way, the jar that gets published will not have .svn folder. The point that I wanted to make here is that it will not touch your artifact that gets created using gradle build. It will still have your .svn folder.
But if you want it to be removed from both the places, then the best option is as suggested above.
add a comment |
Say, you have a file which you want to avoid ONLY while publishing to the repository. If you go with as suggested by @TekiusFanatikus
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
you will be able to achieve it but this will also exclude the file/folder etc. from the artifact that you generate using gradle build.
Instead, I would recommend to use the approach as mentioned here gradle documnetation
You can create a task which have your desired exclusion applied
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
and then refer the task while publishing.
publishing {
publications {
api(MavenPublication) {
groupId 'org.gradle.sample'
artifactId 'project2-api'
version '2'
artifact apiJar
}
}
}
This way, the jar that gets published will not have .svn folder. The point that I wanted to make here is that it will not touch your artifact that gets created using gradle build. It will still have your .svn folder.
But if you want it to be removed from both the places, then the best option is as suggested above.
add a comment |
Say, you have a file which you want to avoid ONLY while publishing to the repository. If you go with as suggested by @TekiusFanatikus
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
you will be able to achieve it but this will also exclude the file/folder etc. from the artifact that you generate using gradle build.
Instead, I would recommend to use the approach as mentioned here gradle documnetation
You can create a task which have your desired exclusion applied
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
and then refer the task while publishing.
publishing {
publications {
api(MavenPublication) {
groupId 'org.gradle.sample'
artifactId 'project2-api'
version '2'
artifact apiJar
}
}
}
This way, the jar that gets published will not have .svn folder. The point that I wanted to make here is that it will not touch your artifact that gets created using gradle build. It will still have your .svn folder.
But if you want it to be removed from both the places, then the best option is as suggested above.
Say, you have a file which you want to avoid ONLY while publishing to the repository. If you go with as suggested by @TekiusFanatikus
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
you will be able to achieve it but this will also exclude the file/folder etc. from the artifact that you generate using gradle build.
Instead, I would recommend to use the approach as mentioned here gradle documnetation
You can create a task which have your desired exclusion applied
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
and then refer the task while publishing.
publishing {
publications {
api(MavenPublication) {
groupId 'org.gradle.sample'
artifactId 'project2-api'
version '2'
artifact apiJar
}
}
}
This way, the jar that gets published will not have .svn folder. The point that I wanted to make here is that it will not touch your artifact that gets created using gradle build. It will still have your .svn folder.
But if you want it to be removed from both the places, then the best option is as suggested above.
answered Jul 29 '16 at 20:53
Neeraj SinghNeeraj Singh
34139
34139
add a comment |
add a comment |
I think you can use 'exclude' method with filefilter. Just add it under 'from' in publications block.
I've tried 3 different configuration (See update 2) without success. Not sure if I implemented what you had in mind.
– TekiusFanatikus
May 12 '16 at 12:21
It looks like your components.java is wrong try specifying the artifact explicitly like artifact file("path-to-jar/jar.jar").
– user3450486
May 12 '16 at 15:54
Not by any chance you could pseudo code something for me? So far, any attempts to append artifact with exclude, brings up the same error.
– TekiusFanatikus
May 16 '16 at 15:08
add a comment |
I think you can use 'exclude' method with filefilter. Just add it under 'from' in publications block.
I've tried 3 different configuration (See update 2) without success. Not sure if I implemented what you had in mind.
– TekiusFanatikus
May 12 '16 at 12:21
It looks like your components.java is wrong try specifying the artifact explicitly like artifact file("path-to-jar/jar.jar").
– user3450486
May 12 '16 at 15:54
Not by any chance you could pseudo code something for me? So far, any attempts to append artifact with exclude, brings up the same error.
– TekiusFanatikus
May 16 '16 at 15:08
add a comment |
I think you can use 'exclude' method with filefilter. Just add it under 'from' in publications block.
I think you can use 'exclude' method with filefilter. Just add it under 'from' in publications block.
answered May 11 '16 at 20:33
user3450486user3450486
75110
75110
I've tried 3 different configuration (See update 2) without success. Not sure if I implemented what you had in mind.
– TekiusFanatikus
May 12 '16 at 12:21
It looks like your components.java is wrong try specifying the artifact explicitly like artifact file("path-to-jar/jar.jar").
– user3450486
May 12 '16 at 15:54
Not by any chance you could pseudo code something for me? So far, any attempts to append artifact with exclude, brings up the same error.
– TekiusFanatikus
May 16 '16 at 15:08
add a comment |
I've tried 3 different configuration (See update 2) without success. Not sure if I implemented what you had in mind.
– TekiusFanatikus
May 12 '16 at 12:21
It looks like your components.java is wrong try specifying the artifact explicitly like artifact file("path-to-jar/jar.jar").
– user3450486
May 12 '16 at 15:54
Not by any chance you could pseudo code something for me? So far, any attempts to append artifact with exclude, brings up the same error.
– TekiusFanatikus
May 16 '16 at 15:08
I've tried 3 different configuration (See update 2) without success. Not sure if I implemented what you had in mind.
– TekiusFanatikus
May 12 '16 at 12:21
I've tried 3 different configuration (See update 2) without success. Not sure if I implemented what you had in mind.
– TekiusFanatikus
May 12 '16 at 12:21
It looks like your components.java is wrong try specifying the artifact explicitly like artifact file("path-to-jar/jar.jar").
– user3450486
May 12 '16 at 15:54
It looks like your components.java is wrong try specifying the artifact explicitly like artifact file("path-to-jar/jar.jar").
– user3450486
May 12 '16 at 15:54
Not by any chance you could pseudo code something for me? So far, any attempts to append artifact with exclude, brings up the same error.
– TekiusFanatikus
May 16 '16 at 15:08
Not by any chance you could pseudo code something for me? So far, any attempts to append artifact with exclude, brings up the same error.
– TekiusFanatikus
May 16 '16 at 15:08
add a comment |
I would like to extend on @Neeraj answer. The problem with the custom JAR approach is with multi-module projects, in which the POM would not contain inner-project dependencies and will also be missing out external dependencies (they will be only part of the dependency-management section). This is in contrast to using the from components.java
approach in which the POM would turn out to be fine.
In order to overcome this, there is a need to manually edit the POM file. This is a pretty dirty solution, but the only one I could find:
project.afterEvaluate {
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
publishing {
publications {
api(MavenPublication) {
artifact apiJar
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
project.configurations.runtime.allDependencies.forEach { d ->
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", d.group)
dependencyNode.appendNode("artifactId", d.name)
dependencyNode.appendNode("version", d.version)
}
}
}
}
}
artifactoryPublish {
publications('api')
}
}
Update:
For anyone using the dependency-management plugin io.spring.dependency-management
, here's a way of correctly injecting the versions of all the dependencies into the POM:
def version = {
if (d.version != null) d.version
else dependencyManagement.managedVersions["${d.group}:${d.name}"]
}
dependencyNode.appendNode("version", version())
add a comment |
I would like to extend on @Neeraj answer. The problem with the custom JAR approach is with multi-module projects, in which the POM would not contain inner-project dependencies and will also be missing out external dependencies (they will be only part of the dependency-management section). This is in contrast to using the from components.java
approach in which the POM would turn out to be fine.
In order to overcome this, there is a need to manually edit the POM file. This is a pretty dirty solution, but the only one I could find:
project.afterEvaluate {
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
publishing {
publications {
api(MavenPublication) {
artifact apiJar
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
project.configurations.runtime.allDependencies.forEach { d ->
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", d.group)
dependencyNode.appendNode("artifactId", d.name)
dependencyNode.appendNode("version", d.version)
}
}
}
}
}
artifactoryPublish {
publications('api')
}
}
Update:
For anyone using the dependency-management plugin io.spring.dependency-management
, here's a way of correctly injecting the versions of all the dependencies into the POM:
def version = {
if (d.version != null) d.version
else dependencyManagement.managedVersions["${d.group}:${d.name}"]
}
dependencyNode.appendNode("version", version())
add a comment |
I would like to extend on @Neeraj answer. The problem with the custom JAR approach is with multi-module projects, in which the POM would not contain inner-project dependencies and will also be missing out external dependencies (they will be only part of the dependency-management section). This is in contrast to using the from components.java
approach in which the POM would turn out to be fine.
In order to overcome this, there is a need to manually edit the POM file. This is a pretty dirty solution, but the only one I could find:
project.afterEvaluate {
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
publishing {
publications {
api(MavenPublication) {
artifact apiJar
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
project.configurations.runtime.allDependencies.forEach { d ->
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", d.group)
dependencyNode.appendNode("artifactId", d.name)
dependencyNode.appendNode("version", d.version)
}
}
}
}
}
artifactoryPublish {
publications('api')
}
}
Update:
For anyone using the dependency-management plugin io.spring.dependency-management
, here's a way of correctly injecting the versions of all the dependencies into the POM:
def version = {
if (d.version != null) d.version
else dependencyManagement.managedVersions["${d.group}:${d.name}"]
}
dependencyNode.appendNode("version", version())
I would like to extend on @Neeraj answer. The problem with the custom JAR approach is with multi-module projects, in which the POM would not contain inner-project dependencies and will also be missing out external dependencies (they will be only part of the dependency-management section). This is in contrast to using the from components.java
approach in which the POM would turn out to be fine.
In order to overcome this, there is a need to manually edit the POM file. This is a pretty dirty solution, but the only one I could find:
project.afterEvaluate {
task apiJar(type: Jar) {
baseName "publishing-api"
from sourceSets.main.output
exclude '**/.svn/**'
}
publishing {
publications {
api(MavenPublication) {
artifact apiJar
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
project.configurations.runtime.allDependencies.forEach { d ->
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", d.group)
dependencyNode.appendNode("artifactId", d.name)
dependencyNode.appendNode("version", d.version)
}
}
}
}
}
artifactoryPublish {
publications('api')
}
}
Update:
For anyone using the dependency-management plugin io.spring.dependency-management
, here's a way of correctly injecting the versions of all the dependencies into the POM:
def version = {
if (d.version != null) d.version
else dependencyManagement.managedVersions["${d.group}:${d.name}"]
}
dependencyNode.appendNode("version", version())
edited Nov 28 '18 at 21:07
answered Nov 26 '18 at 17:17
Eyal RothEyal Roth
1,45922131
1,45922131
add a comment |
add a comment |
I appended the following at the root level in my build.gradle
and it seems to work:
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
add a comment |
I appended the following at the root level in my build.gradle
and it seems to work:
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
add a comment |
I appended the following at the root level in my build.gradle
and it seems to work:
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
I appended the following at the root level in my build.gradle
and it seems to work:
sourceSets {
main {
java {
exclude '**/.svn/**'
}
}
}
answered May 27 '16 at 16:38
TekiusFanatikusTekiusFanatikus
1,39752762
1,39752762
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37171372%2fexcluding-files-and-folders-during-plugin-publishing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown