-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NativeLibraryArtifact for deploying shared libraries (#25)
* First pass at adding NativeLibraryArtifact Based off NativeExecutableArtifact * fix
- Loading branch information
1 parent
2e7c8ca
commit 2e1b86d
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/edu/wpi/first/deployutils/deploy/artifact/NativeLibraryArtifact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package edu.wpi.first.deployutils.deploy.artifact; | ||
|
||
import java.io.File; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.gradle.api.provider.Property; | ||
import org.gradle.api.tasks.util.PatternFilterable; | ||
import org.gradle.api.tasks.util.PatternSet; | ||
import org.gradle.nativeplatform.SharedLibraryBinarySpec; | ||
import org.gradle.api.Task; | ||
import org.gradle.api.provider.Provider; | ||
|
||
import edu.wpi.first.deployutils.deploy.cache.CacheMethod; | ||
import edu.wpi.first.deployutils.deploy.context.DeployContext; | ||
import edu.wpi.first.deployutils.deploy.target.RemoteTarget; | ||
|
||
public class NativeLibraryArtifact extends AbstractArtifact implements CacheableArtifact { | ||
|
||
private final Property<CacheMethod> cacheMethod; | ||
|
||
@Inject | ||
public NativeLibraryArtifact(String name, RemoteTarget target) { | ||
super(name, target); | ||
filename = target.getProject().getObjects().property(String.class); | ||
binarySpec = target.getProject().getObjects().property(SharedLibraryBinarySpec.class); | ||
cacheMethod = target.getProject().getObjects().property(CacheMethod.class); | ||
|
||
linkTaskProvider = target.getProject().getProviders().provider(() -> { | ||
return binarySpec.get().getTasks().getLink(); | ||
}); | ||
|
||
dependsOn(linkTaskProvider); | ||
} | ||
|
||
private final Provider<Task> linkTaskProvider; | ||
|
||
@Override | ||
public Property<CacheMethod> getCacheMethod() { | ||
return cacheMethod; | ||
} | ||
|
||
private final Property<String> filename; | ||
|
||
public Property<String> getFilename() { | ||
return filename; | ||
} | ||
|
||
private Property<SharedLibraryBinarySpec> binarySpec; | ||
|
||
public Property<SharedLibraryBinarySpec> getBinary() { | ||
return binarySpec; | ||
} | ||
|
||
private final PatternFilterable libraryFilter = new PatternSet(); | ||
|
||
public PatternFilterable getLibraryFilter() { | ||
return libraryFilter; | ||
} | ||
|
||
protected File getDeployedFile() { | ||
return binarySpec.get().getSharedLibraryFile(); | ||
} | ||
|
||
@Override | ||
public void deploy(DeployContext context) { | ||
CacheMethod cm = cacheMethod.getOrElse(null); | ||
|
||
File libFile = getDeployedFile(); | ||
context.put(libFile, getFilename().getOrElse(libFile.getName()), cm); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters