1+ /*
2+ * Copyright 2013-2024, Seqera Labs
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package nextflow.r
18+
19+ import java.nio.file.Path
20+ import java.nio.file.Paths
21+
22+ import groovy.transform.CompileStatic
23+ import groovy.util.logging.Slf4j
24+ import nextflow.packages.PackageProvider
25+ import nextflow.packages.PackageSpec
26+ import org.pf4j.Extension
27+
28+ /**
29+ * R/CRAN package provider implementation for Wave integration
30+ *
31+ * This is a placeholder implementation that allows R packages to be
32+ * specified in the package directive for Wave container building.
33+ *
34+ * @author Edmund Miller <[email protected] > 35+ */
36+ @Slf4j
37+ @CompileStatic
38+ @Extension
39+ class RPackageProvider implements PackageProvider {
40+
41+ @Override
42+ String getName () {
43+ return " r"
44+ }
45+
46+ @Override
47+ boolean isAvailable () {
48+ // Check if R is installed on the system
49+ try {
50+ def proc = [' R' , ' --version' ]. execute()
51+ proc. waitFor()
52+ return proc. exitValue() == 0
53+ } catch (Exception e) {
54+ log. debug " R is not available: ${ e.message} "
55+ return false
56+ }
57+ }
58+
59+ @Override
60+ Path createEnvironment (PackageSpec spec ) {
61+ log. info " R package management is currently a placeholder for Wave integration"
62+ log. info " Packages requested: ${ spec.entries} "
63+
64+ // Return a dummy path for now
65+ // In a full implementation, this would:
66+ // 1. Create an R library directory
67+ // 2. Install packages using pak::pak() or install.packages()
68+ // 3. Return the library path
69+ return Paths . get(" /tmp/r-packages-placeholder" )
70+ }
71+
72+ @Override
73+ String getActivationScript (Path envPath ) {
74+ // Return script to set R_LIBS_USER to the environment path
75+ return """
76+ # R environment activation (placeholder)
77+ export R_LIBS_USER=${ envPath}
78+ """ . stripIndent()
79+ }
80+
81+ @Override
82+ boolean supportsSpec (PackageSpec spec ) {
83+ return spec. provider?. toLowerCase() in [' r' , ' cran' , ' pak' , ' bioconductor' ]
84+ }
85+
86+ @Override
87+ Object getConfig () {
88+ // Return R-specific configuration
89+ return [
90+ repositories : [' https://cloud.r-project.org/' , ' https://bioconductor.org/packages/release/bioc' ],
91+ installMethod : ' pak'
92+ ]
93+ }
94+ }
0 commit comments