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

Update publication artifact collection logic #306

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
build

gradle.properties

build/
.gradle/

.idea/
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,28 +444,52 @@ export BINTRAY_USER=<Your Bintray user name>
export BINTRAY_KEY=<Your Bintray API Key>
export BINTRAY_ORG=<Your Bintray organization name>
```
## Publish the modified plugin to Maven local

In order to test the modified plugin, it must be published to Maven local where the tests will resolve it.

The publication can be done by running:
```
> ./gradlew publishtToMavenLocal
```

---
**NOTE**

If you have changed the plugin version in `gradle.properties`, you will need to change it in the test projects.
See `src/test/resources/gradle/projects` for this.

---

## Running the build with or without tests
To build the code using the gradle wrapper in Unix run:
```
> ./gradlew clean build
> ./gradlew build
```

To build the code using the gradle wrapper in Windows run:
```
> gradlew clean build
> gradlew build
```

To build the code using the environment gradle run:
```
> gradle clean build
> gradle build
```

To build the code without running the tests, add to the "clean build" command the "-x test" option, for example:
```
> ./gradlew clean build -x test
> ./gradlew build -x test
```

---
**NOTE**

The tests will use the Gradle version pointed at by `GRADLE_HOME`.
If not set, it will use the wrapper of this project.

---

<a name="Release_Notes"/>

# Release Notes
Expand Down
23 changes: 11 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ repositories {
}

dependencies {
compile gradleApi()
compile('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') {
implementation gradleApi()
implementation('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') {
exclude(module: 'groovy')
}
compile('org.apache.maven.resolver:maven-resolver-ant-tasks:1.2.0')
// provided by Gradle
compileOnly('org.apache.maven:maven-project:2.0.11')
testRuntime('org.apache.maven:maven-project:2.0.11')
testCompile('org.spockframework:spock-core:0.7-groovy-2.0') {
implementation('org.apache.maven.resolver:maven-resolver-ant-tasks:1.2.0')
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd exchange implementation for api (except for gradleApi()) as those dependencies are required for compilation & consumers that extend the plugin

implementation('org.apache.maven:maven-core:3.0.5')

testImplementation('org.spockframework:spock-core:0.7-groovy-2.0') {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be a good idea to update this dependency to a version that closely matches the Groovy version provided by gradleApi(), after all Spock is very sensitive to Groovy AST changes

exclude(module: 'groovy-all')
}
testCompile('com.jfrog.bintray.client:bintray-client-java-api:0.4')
testCompile('com.jfrog.bintray.client:bintray-client-java-service:0.4')
testCompile('com.jfrog.bintray.client:bintray-client-java-impl:0.1.1')
testCompile('org.codehaus.gpars:gpars:1.2.1')
testCompile('org.codehaus.groovy.modules.http-builder:http-builder:0.7.1')
testImplementation('com.jfrog.bintray.client:bintray-client-java-api:0.4')
testImplementation('com.jfrog.bintray.client:bintray-client-java-service:0.4')
testImplementation('com.jfrog.bintray.client:bintray-client-java-impl:0.1.1')
testImplementation('org.codehaus.gpars:gpars:1.2.1')
testImplementation('org.codehaus.groovy.modules.http-builder:http-builder:0.7.1')
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.gradle.api.file.CopySpec
import org.gradle.api.publish.Publication
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
Expand Down Expand Up @@ -539,34 +540,21 @@ class BintrayUploadTask extends DefaultTask {
}

Artifact[] collectArtifacts(Publication publication) {
if (!publication instanceof MavenPublication) {
if (!publication instanceof MavenPublicationInternal) {
logger.info "{} can only use maven publications - skipping {}.", path, publication.name
return []
}
def artifacts = publication.artifacts.findResults {
boolean signedArtifact = (it instanceof org.gradle.plugins.signing.Signature)
def signedExtension = signedArtifact ? it.toSignArtifact.getExtension() : null
Copy link
Contributor

Choose a reason for hiding this comment

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

Question - With the new API, we no longer need this?
This code checks whether this is artifact is the signature file, and adds it to the list of uploaded artifact,s with the signature extension.

Choose a reason for hiding this comment

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

toSignArtifact was deprecated and removed, this PR would also fix #300

Choose a reason for hiding this comment

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

@eyalbe4 so, to answer your question: yes, we no longer need this.
In fact the current code is wrong as currently publishing signed artifacts does not work at all (#300 ).
Would be great to have this merged and released.

Copy link
Author

Choose a reason for hiding this comment

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

I confirm as well that these changes still properly publish the signature files.

def artifacts = publication.asNormalisedPublication().allArtifacts.findResults {
new Artifact(
name: publication.artifactId,
groupId: publication.groupId,
version: publication.version,
extension: it.extension,
type: it.extension,
classifier: it.classifier,
file: it.file,
signedExtension: signedExtension
file: it.file
)
}

// Add the pom file
artifacts << new Artifact(
name: publication.artifactId,
groupId: publication.groupId,
version: publication.version,
extension: 'pom',
type: 'pom',
file: publication.asNormalisedPublication().pomFile
)
artifacts
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,3 @@ def getTestFile = { fileName ->
}

apply from: getTestFile("${testName}.gradle")

task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,3 @@ def getTestFile = { fileName ->
}

apply from: getTestFile("${testName}.gradle")

task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}